netapp_ontap.resources.flexcache API documentation
Description: Copyright &copy; 2020 NetApp Inc. All rights reserved …

# Module `netapp_ontap.resources.flexcache`

Copyright © 2020 NetApp Inc. All rights reserved.

## Overview

FlexCache is a persistent cache of an origin volume. An origin volume can only be a FlexVol while a FlexCache is always a FlexGroup. The following relationship configurations are supported:

- Intra-Vserver where FlexCache and the corresponding origin volume reside in the same Vserver.
- Cross-Vserver but intra-cluster where FlexCache and the origin volume reside in the same cluster but belong to different Vservers.
- Cross-cluster where FlexCache and the origin volume reside in different clusters. FlexCache supports fan-out and more than one FlexCache can be created from one origin volume. This API retrieves and manages FlexCache configurations in the cache cluster.

## FlexCache APIs

The following APIs can be used to perform operations related with FlexCache:

- GET /api/storage/flexcache/flexcaches
- GET /api/storage/flexcache/flexcaches/{uuid}
- POST /api/storage/flexcache/flexcaches
- DELETE /api/storage/flexcache/flexcaches/{uuid}

## Examples

### Creating a FlexCache

The POST request is used to create a FlexCache.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Flexcache

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Flexcache()
        resource.aggregates = [{"name": "aggr_1"}]
        resource.name = "fc_333"
        resource.origins = [{"svm": {"name": "vs_3"}, "volume": {"name": "vol_o1"}}]
        resource.svm.name = "vs_1"
        resource.post(hydrate=True)
        print(resource)

Try it out

    Flexcache(
        {
            "svm": {"name": "vs_1"},
            "aggregates": [{"name": "aggr_1"}],
            "name": "fc_333",
            "origins": [{"svm": {"name": "vs_3"}, "volume": {"name": "vol_o1"}}],
        }
    )

curl -X POST "https:///api/storage/flexcache/flexcaches" -H "accept: application/json" -H "Content-Type: application/json" -d "{ "aggregates": [ { "name": "aggr_1" } ], "name": "fc_333", "origins": [ { "svm": { "name": "vs_3" }, "volume": { "name": "vol_o1" } } ], "svm": { "name": "vs_1" }, "path": "/fc_333", "prepopulate": { "dir_paths": [ "/dir1" ] } }"

# The response:

{ "job": { "uuid": "e751dd5d-0f3c-11e9-8b2b-0050568e0b79", "_links": { "self": { "href": "/api/cluster/jobs/e751dd5d-0f3c-11e9-8b2b-0050568e0b79" } } } }

    ### Retrieving FlexCache attributes
    The GET request is used to retrieve FlexCache attributes. The object includes a large set of fields which can be expensive to retrieve. Most notably, the fields size, guarantee.type, aggregates, path, origins.ip_address, origins.size, and origins.state are expensive to retrieve. The recommended method to use this API is to filter and retrieve only the required fields.
    ```python
    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Flexcache

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(Flexcache.get_collection()))

Try it out

    [
        Flexcache(
            {
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/flexcaches/04d5e07b-0ebe-11e9-8180-0050568e0b79"
                    }
                },
                "name": "fc_322",
                "uuid": "04d5e07b-0ebe-11e9-8180-0050568e0b79",
            }
        ),
        Flexcache(
            {
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/flexcaches/47902654-0ea4-11e9-8180-0050568e0b79"
                    }
                },
                "name": "fc_321",
                "uuid": "47902654-0ea4-11e9-8180-0050568e0b79",
            }
        ),
        Flexcache(
            {
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/flexcaches/77e911ff-0ebe-11e9-8180-0050568e0b79"
                    }
                },
                "name": "fc_323",
                "uuid": "77e911ff-0ebe-11e9-8180-0050568e0b79",
            }
        ),
        Flexcache(
            {
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/flexcaches/ddb42bbc-0e95-11e9-8180-0050568e0b79"
                    }
                },
                "name": "fc_32",
                "uuid": "ddb42bbc-0e95-11e9-8180-0050568e0b79",
            }
        ),
        Flexcache(
            {
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/flexcaches/ec774932-0f3c-11e9-8b2b-0050568e0b79"
                    }
                },
                "name": "fc_333",
                "uuid": "ec774932-0f3c-11e9-8b2b-0050568e0b79",
            }
        ),
    ]

### Retrieving the attributes of a FlexCache

The GET request is used to retrieve the attributes of a FlexCache. The object includes a large set of fields which can be expensive to retrieve. Most notably, the fields size, guarantee.type, aggregates, path, origins.ip_address, origins.size, and origins.state are expensive to retrieve. The recommended method to use this API is to filter and retrieve only the required fields.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Flexcache

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Flexcache(uuid="ec774932-0f3c-11e9-8b2b-0050568e0b79")
        resource.get()
        print(resource)

Try it out

    Flexcache(
        {
            "svm": {"uuid": "e708fbe2-0e92-11e9-8180-0050568e0b79", "name": "vs_1"},
            "guarantee": {"type": "volume"},
            "aggregates": [
                {"name": "aggr_1", "uuid": "26f34b76-88f8-4a47-b5e0-d8e901fb1114"}
            ],
            "size": 4294967296,
            "_links": {
                "self": {
                    "href": "/api/storage/flexcache/flexcaches/ec774932-0f3c-11e9-8b2b-0050568e0b79"
                }
            },
            "name": "fc_333",
            "origins": [
                {
                    "svm": {"uuid": "8aa2cd28-0e92-11e9-b391-0050568e4115", "name": "vs_3"},
                    "size": 20971520,
                    "cluster": {
                        "uuid": "50733f81-0e90-11e9-b391-0050568e4115",
                        "name": "node2",
                    },
                    "volume": {
                        "uuid": "2bc957dd-2617-4afb-8d2f-66ac6070d313",
                        "name": "vol_o1",
                    },
                    "ip_address": "10.140.103.175",
                    "state": "online",
                    "create_time": "2019-01-03T15:19:55+05:30",
                }
            ],
            "uuid": "ec774932-0f3c-11e9-8b2b-0050568e0b79",
        }
    )

### Deleting a FlexCache

The DELETE request is used to delete a FlexCache.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Flexcache

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Flexcache(uuid="ec774932-0f3c-11e9-8b2b-0050568e0b79")
        resource.delete()

### Modifying a FlexCache volume

Use the PATCH request to update a FlexCache volume.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Flexcache

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Flexcache(uuid="ec774932-0f3c-11e9-8b2b-0050568e0b79")
        resource.prepopulate.dir_paths = ["/dir1"]
        resource.patch()

## Classes

`class Flexcache (*args, **kwargs)`

  Defines the cache endpoint of FlexCache.

  Initialize the instance of the resource.

  Any keyword arguments are set on the instance as properties. For example, if the class was named 'MyResource', then this statement would be true:

      MyResource(name='foo').name == 'foo'

  ## Args

  `*args`
    Each positional argument represents a parent key as used in the URL of the object. That is, each value will be used to fill in a segment of the URL which refers to some parent object. The order of these arguments must match the order they are specified in the URL, from left to right.
  `**kwargs`
    each entry will have its key set as an attribute name on the instance and its value will be the value of that attribute.

  ### Ancestors

  - Resource

  ### Static methods

  `def count_collection(*args, connection: HostConnection = None, **kwargs) -> int`

    Retrieves FlexCache in the cluster.

    ### Expensive properties

    There is an added cost to retrieving values for these properties. They are not included by default in GET results and must be explicitly requested using the `fields` query parameter. See `Requesting specific fields` to learn more. * `origins.ip_address` - IP address of origin. * `origins.size` - Physical size of origin. * `origins.state` - State of origin. * `size` - Physical size of FlexCache. * `guarantee.type` - Space guarantee style of FlexCache. * `aggregates.name` or `aggregates.uuid` - Name or UUID of aggregrate of FlexCache volume. * `path` - Fully-qualified path of the owning SVM's namespace where the FlexCache is mounted.

    ### Related ONTAP commands

    - `volume flexcache show`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Fetch a count of all objects of this type from the host.

    This calls GET on the object to determine the number of records. It is more efficient than calling get_collection() because it will not construct any objects. Query parameters can be passed in as kwargs to determine a count of objects that match some filtered criteria.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to get the count of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. These query parameters can affect the count. A return_records query param will be ignored.

    ## Returns

    On success, returns an integer count of the objects of this type. On failure, returns -1.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400, or if there is no connection available to use either passed in or on the library.

  `def delete_collection(*args, body: typing.Union = None, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Deletes a FlexCache. If a FlexCache volume is online, it is offlined before deletion.

    ### Related ONTAP commands

    - `volume flexcache delete`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Delete all objects in a collection which match the given query.

    All records on the host which match the query will be deleted.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to delete the collection of bars for a particular foo, the foo.name value should be passed.
    `body`
      The body of the delete request. This could be a Resource instance or a dictionary object.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. Only resources matching this query will be patched.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def find(*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves FlexCache in the cluster.

    ### Expensive properties

    There is an added cost to retrieving values for these properties. They are not included by default in GET results and must be explicitly requested using the `fields` query parameter. See `Requesting specific fields` to learn more. * `origins.ip_address` - IP address of origin. * `origins.size` - Physical size of origin. * `origins.state` - State of origin. * `size` - Physical size of FlexCache. * `guarantee.type` - Space guarantee style of FlexCache. * `aggregates.name` or `aggregates.uuid` - Name or UUID of aggregrate of FlexCache volume. * `path` - Fully-qualified path of the owning SVM's namespace where the FlexCache is mounted.

    ### Related ONTAP commands

    - `volume flexcache show`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Find an instance of an object on the host given a query.

    The host will be queried with the provided key/value pairs to find a matching resource. If 0 are found, None will be returned. If more than 1 is found, an error will be raised or returned. If there is exactly 1 matching record, then it will be returned.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to find a bar for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A `Resource` object containing the details of the object or None if no matches were found.

    ## Raises

    `NetAppRestError`: If the API call returned more than 1 matching resource.

  `def get_collection(*args, connection: HostConnection = None, max_records: int = None, **kwargs) -> typing.Iterable`

    Retrieves FlexCache in the cluster.

    ### Expensive properties

    There is an added cost to retrieving values for these properties. They are not included by default in GET results and must be explicitly requested using the `fields` query parameter. See `Requesting specific fields` to learn more. * `origins.ip_address` - IP address of origin. * `origins.size` - Physical size of origin. * `origins.state` - State of origin. * `size` - Physical size of FlexCache. * `guarantee.type` - Space guarantee style of FlexCache. * `aggregates.name` or `aggregates.uuid` - Name or UUID of aggregrate of FlexCache volume. * `path` - Fully-qualified path of the owning SVM's namespace where the FlexCache is mounted.

    ### Related ONTAP commands

    - `volume flexcache show`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Fetch a list of all objects of this type from the host.

    This is a lazy fetch, making API calls only as necessary when the result of this call is iterated over. For instance, if max_records is set to 5, then iterating over the collection causes an API call to be sent to the server once for every 5 records. If the client stops iterating before getting to the 6th record, then no additional API calls are made.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to get the collection of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `max_records`
      The maximum number of records to return per call
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A list of `Resource` objects

    ## Raises

    `NetAppRestError`: If there is no connection available to use either passed in or on the library. This would be not be raised when get_collection() is called, but rather when the result is iterated.

  `def patch_collection(body: dict, *args, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Prepopulates a FlexCache volume in the cluster.

    ### Required properties

    - `uuid` - FlexCache volume UUID.
    - `prepopulate.dir_paths` - List of directory-paths to be prepopulated for the FlexCache volume.

    ### Default property values

    If not specified in PATCH, the following default property value is assigned: * `prepopulate.recurse` - Default value is "true".

    ### Related ONTAP commands

    - `volume flexcache prepopulate start`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Patch all objects in a collection which match the given query.

    All records on the host which match the query will be patched with the provided body.

    ## Args

    `body`
      A dictionary of name/value pairs to set on all matching members of the collection.
    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to patch the collection of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. Only resources matching this query will be patched.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  ### Methods

  `def delete(self, body: typing.Union = None, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Deletes a FlexCache. If a FlexCache volume is online, it is offlined before deletion.

    ### Related ONTAP commands

    - `volume flexcache delete`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Send a deletion request to the host for this object.

    ## Args

    `body`
      The body of the delete request. This could be a Resource instance or a dictionary object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def get(self, **kwargs) -> NetAppResponse`

    Retrieves attributes of the FlexCache in the cluster.

    ### Expensive properties

    There is an added cost to retrieving values for these properties. They are included by default in GET. The recommended method to use this API is to filter and retrieve only the required fields. See `Requesting specific fields` to learn more. * `origins.ip_address` - IP address of origin. * `origins.size` - Physical size of origin. * `origins.state` - State of origin. * `size` - Physical size of FlexCache. * `guarantee.type` - Space guarantee style of FlexCache. * `aggregates.name` or `aggregates.uuid` - Name or UUID of aggregrate of FlexCache volume. * `path` - Fully-qualified path of the owning SVM's namespace where the FlexCache is mounted.

    ### Related ONTAP commands

    - `volume flexcache show`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Fetch the details of the object from the host.

    Requires the keys to be set (if any). After returning, new or changed properties from the host will be set on the instance.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def patch(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Prepopulates a FlexCache volume in the cluster.

    ### Required properties

    - `uuid` - FlexCache volume UUID.
    - `prepopulate.dir_paths` - List of directory-paths to be prepopulated for the FlexCache volume.

    ### Default property values

    If not specified in PATCH, the following default property value is assigned: * `prepopulate.recurse` - Default value is "true".

    ### Related ONTAP commands

    - `volume flexcache prepopulate start`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Send the difference in the object's state to the host as a modification request.

    Calculates the difference in the object's state since the last time we interacted with the host and sends this in the request body.

    ## Args

    `hydrate`
      If set to True, after the response is received from the call, a a GET call will be made to refresh all fields of the object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will normally be sent as query parameters to the host. If any of these pairs are parameters that are sent as formdata then only parameters of that type will be accepted and all others will be discarded.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def post(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Creates a FlexCache in the cluster.

    ### Required properties

    - `name` - Name of FlexCache volume.
    - `origins.volume.name` or `origins.volume.uuid` - Name or UUID of origin volume.
    - `origins.svm.name` - Name of origin Vserver.
    - `svm.name` or `svm.uuid` - Name or UUID of Vserver where FlexCache will be created.

    ### Recommended optional properties

    - `path` - Path to mount the FlexCache volume
    - `preopopulate.dir_paths` - List of directory-paths to be prepopulated for the FlexCache volume.

    ### Default property values

    If not specified in POST, the following default property values are assigned: * `size` - 10% of origin volume size or 1GB per constituent, whichever is greater. * `guarantee.type` - Same as for a non-FlexCache FlexGroup volume. * `constituents_per_aggregate` - 4 if aggregates.name or aggregates.uuid is used. * `use_tiered_aggregate` - false if aggr-list is not used. This property is only used when auto-provisioning a FlexCache volume. * `is_disconnected_mode_off_for_locks` - false. This property specifies if the origin will honor the cache side locks when doing the lock checks in the disconnected mode.

    ### Related ONTAP commands

    - `volume flexcache create`
    - `volume flexcache prepopulate start`

    ### Learn more

    - `DOC /storage/flexcache/flexcaches`

    Send this object to the host as a creation request.

    ## Args

    `hydrate`
      If set to True, after the response is received from the call, a a GET call will be made to refresh all fields of the object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will normally be sent as query parameters to the host. If any of these pairs are parameters that are sent as formdata then only parameters of that type will be accepted and all others will be discarded.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  ### Inherited members

  - `Resource`:
    - `from_dict`
    - `get_collection_url`
    - `get_connection`
    - `instance_location`
    - `path_keys`
    - `poll`
    - `set_connection`
    - `to_dict`
`class FlexcacheSchema (*, only: typing.Union = None, exclude: typing.Union = (), many: bool = False, context: typing.Dict = None, load_only: typing.Union = (), dump_only: typing.Union = (), partial: typing.Union = False, unknown: str = None)`

  The fields of the Flexcache object

  ### Ancestors

  - netapp_ontap.resource.ResourceSchema
  - marshmallow.schema.Schema
  - marshmallow.base.SchemaABC

  ### Class variables

  `aggregates GET POST`

    The aggregates field of the flexcache.

  `constituents_per_aggregate GET POST`

    Number of FlexCache constituents per aggregate when the 'aggregates' field is mentioned.

  `guarantee GET POST`

    The guarantee field of the flexcache.

  `links GET`

    The links field of the flexcache.

  `name GET POST PATCH`

    FlexCache name

    Example: vol1

  `origins GET POST`

    The origins field of the flexcache.

  `path GET POST`

    The fully-qualified path in the owning SVM's namespace at which the FlexCache is mounted. The path is case insensitive and must be unique within a SVM's namespace. Path must begin with '/' and must not end with '/'. Only one FlexCache be mounted at any given junction path.

    Example: /user/my_fc

  `prepopulate POST PATCH`

    The prepopulate field of the flexcache.

  `size GET POST`

    Physical size of the FlexCache. The recommended size for a FlexCache is 10% of the origin volume. The minimum FlexCache constituent size is 1GB.

  `svm GET POST`

    The svm field of the flexcache.

  `use_tiered_aggregate GET POST`

    Specifies whether or not a Fabricpool-enabled aggregate can be used in FlexCache creation. The use_tiered_aggregate is only used when auto-provisioning a FlexCache volume.

  `uuid GET`

    FlexCache UUID. Unique identifier for the FlexCache.

    Example: 1cd8a442-86d1-11e0-ae1c-123478563412