# Module `netapp_ontap.resources.flexcache_origin`

Copyright © 2021 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 the origin of FlexCache onfigurations in the origin cluster.

## FlexCache APIs

The following APIs can be used to perform operations related to the origin of a FlexCache:

- GET /api/storage/flexcache/origins
- GET /api/storage/flexcache/origins/{uuid}
- PATCH /api/storage/flexcache/origins/{uuid}

## Examples

### Retrieving origins of FlexCache attributes

The GET request is used to retrieve the origins of FlexCache attributes.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FlexcacheOrigin

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

Try it out

    [
        FlexcacheOrigin(
            {
                "uuid": "2bc957dd-2617-4afb-8d2f-66ac6070d313",
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/origins/2bc957dd-2617-4afb-8d2f-66ac6070d313"
                    }
                },
                "name": "vol_o1",
            }
        ),
        FlexcacheOrigin(
            {
                "uuid": "80fcaee4-0dc2-488b-afb8-86d28a34cda8",
                "_links": {
                    "self": {
                        "href": "/api/storage/flexcache/origins/80fcaee4-0dc2-488b-afb8-86d28a34cda8"
                    }
                },
                "name": "vol_1",
            }
        ),
    ]

### Retrieving the attributes of an origin volume

The GET request is used to retrieve the attributes of an origin volume.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FlexcacheOrigin

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FlexcacheOrigin(uuid="80fcaee4-0dc2-488b-afb8-86d28a34cda8")
        resource.get()
        print(resource)

Try it out

    FlexcacheOrigin(
        {
            "flexcaches": [
                {
                    "ip_address": "10.140.103.183",
                    "svm": {
                        "name": "vs_1_4",
                        "uuid": "36f68322-0e93-11e9-aed0-0050568eddbe",
                    },
                    "volume": {
                        "name": "fc_42",
                        "uuid": "4e7f9d49-0e96-11e9-aed0-0050568eddbe",
                    },
                    "cluster": {
                        "name": "node4",
                        "uuid": "c32f16b8-0e90-11e9-aed0-0050568eddbe",
                    },
                    "create_time": "2019-01-02T19:27:22+05:30",
                },
                {
                    "ip_address": "10.140.103.183",
                    "svm": {
                        "name": "vs_1_4",
                        "uuid": "36f68322-0e93-11e9-aed0-0050568eddbe",
                    },
                    "volume": {
                        "name": "fc_421",
                        "uuid": "71ee8f36-0ea4-11e9-aed0-0050568eddbe",
                    },
                    "cluster": {
                        "name": "node4",
                        "uuid": "c32f16b8-0e90-11e9-aed0-0050568eddbe",
                    },
                    "create_time": "2019-01-02T21:08:34+05:30",
                },
                {
                    "ip_address": "10.140.103.183",
                    "svm": {
                        "name": "vs_1_4",
                        "uuid": "36f68322-0e93-11e9-aed0-0050568eddbe",
                    },
                    "volume": {"name": "fc_422"},
                    "cluster": {
                        "name": "node4",
                        "uuid": "c32f16b8-0e90-11e9-aed0-0050568eddbe",
                    },
                    "create_time": "2019-01-03T11:14:38+05:30",
                },
                {
                    "ip_address": "10.140.103.179",
                    "svm": {"name": "vs_1", "uuid": "e708fbe2-0e92-11e9-8180-0050568e0b79"},
                    "size": 4294967296,
                    "volume": {
                        "name": "fc_32",
                        "uuid": "ddb42bbc-0e95-11e9-8180-0050568e0b79",
                    },
                    "cluster": {
                        "name": "node3",
                        "uuid": "8eb21b3b-0e90-11e9-8180-0050568e0b79",
                    },
                    "create_time": "2019-01-02T19:24:14+05:30",
                    "state": "online",
                },
                {
                    "ip_address": "10.140.103.179",
                    "svm": {"name": "vs_1", "uuid": "e708fbe2-0e92-11e9-8180-0050568e0b79"},
                    "size": 4294967296,
                    "volume": {
                        "name": "fc_321",
                        "uuid": "47902654-0ea4-11e9-8180-0050568e0b79",
                    },
                    "cluster": {
                        "name": "node3",
                        "uuid": "8eb21b3b-0e90-11e9-8180-0050568e0b79",
                    },
                    "create_time": "2019-01-02T21:07:23+05:30",
                    "state": "online",
                },
                {
                    "ip_address": "10.140.103.179",
                    "svm": {"name": "vs_1", "uuid": "e708fbe2-0e92-11e9-8180-0050568e0b79"},
                    "size": 4294967296,
                    "volume": {
                        "name": "fc_322",
                        "uuid": "04d5e07b-0ebe-11e9-8180-0050568e0b79",
                    },
                    "cluster": {
                        "name": "node3",
                        "uuid": "8eb21b3b-0e90-11e9-8180-0050568e0b79",
                    },
                    "create_time": "2019-01-03T00:11:38+05:30",
                    "state": "online",
                },
                {
                    "ip_address": "10.140.103.179",
                    "svm": {"name": "vs_1", "uuid": "e708fbe2-0e92-11e9-8180-0050568e0b79"},
                    "size": 4294967296,
                    "volume": {
                        "name": "fc_323",
                        "uuid": "77e911ff-0ebe-11e9-8180-0050568e0b79",
                    },
                    "cluster": {
                        "name": "node3",
                        "uuid": "8eb21b3b-0e90-11e9-8180-0050568e0b79",
                    },
                    "create_time": "2019-01-03T00:14:52+05:30",
                    "state": "online",
                },
            ],
            "global_file_locking_enabled": True,
            "block_level_invalidation": False,
            "svm": {"name": "vs_3", "uuid": "8aa2cd28-0e92-11e9-b391-0050568e4115"},
            "uuid": "80fcaee4-0dc2-488b-afb8-86d28a34cda8",
            "_links": {
                "self": {
                    "href": "/api/storage/flexcache/origins/80fcaee4-0dc2-488b-afb8-86d28a34cda8"
                }
            },
            "name": "vol_1",
        }
    )

### Modifying origin options of an origin volume

Use the PATCH request to update options of an origin volume.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FlexcacheOrigin

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FlexcacheOrigin(uuid="1fbc0ebb-2440-11eb-a86c-005056ac8ca0")
        resource.block_level_invalidation = True
        resource.patch()

## Classes

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

  Defines the origin 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 origin of 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. * `flexcaches.ip_address` - IP address of FlexCache. * `flexcaches.size` - Physical size of FlexCache. * `flexcaches.guarantee.type` - Space guarantee style of FlexCache. * `flexcaches.state` - State of FlexCache.

    ### Related ONTAP commands

    - `volume flexcache origin show-caches`

    ### Learn more

    - `DOC /storage/flexcache/origins`

    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 find(*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves origin of 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. * `flexcaches.ip_address` - IP address of FlexCache. * `flexcaches.size` - Physical size of FlexCache. * `flexcaches.guarantee.type` - Space guarantee style of FlexCache. * `flexcaches.state` - State of FlexCache.

    ### Related ONTAP commands

    - `volume flexcache origin show-caches`

    ### Learn more

    - `DOC /storage/flexcache/origins`

    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 origin of 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. * `flexcaches.ip_address` - IP address of FlexCache. * `flexcaches.size` - Physical size of FlexCache. * `flexcaches.guarantee.type` - Space guarantee style of FlexCache. * `flexcaches.state` - State of FlexCache.

    ### Related ONTAP commands

    - `volume flexcache origin show-caches`

    ### Learn more

    - `DOC /storage/flexcache/origins`

    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`

    Modifies origin options for a origin volume in the cluster.

    ### Required properties

    - `uuid` - Origin volume UUID.
    - `block_level_invalidation` - Value for the Block Level Invalidation flag - options {true|false}.

    ### Related ONTAP commands

    - `volume flexcache origin config modify`

    ### Learn more

    - `DOC /storage/flexcache/origins`

    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 get(self, **kwargs) -> NetAppResponse`

    Retrieves attributes of the origin of a FlexCache in the cluster.

    ### Expensive properties

    There is an added cost to retrieving values for these properties. They are included by default in GET results. The recommended method to use this API is to filter and retrieve only the required fields. See `Requesting specific fields` to learn more. * `flexcaches.ip_address` - IP address of FlexCache. * `flexcaches.size` - Physical size of FlexCache. * `flexcaches.guarantee.type` - Space guarantee style of FlexCache. * `flexcaches.state` - State of FlexCache. * `flexcaches.dr_cache` - True if the cache is a DR cache.

    ### Related ONTAP commands

    - `volume flexcache origin show-caches`

    ### Learn more

    - `DOC /storage/flexcache/origins`

    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`

    Modifies origin options for a origin volume in the cluster.

    ### Required properties

    - `uuid` - Origin volume UUID.
    - `block_level_invalidation` - Value for the Block Level Invalidation flag - options {true|false}.

    ### Related ONTAP commands

    - `volume flexcache origin config modify`

    ### Learn more

    - `DOC /storage/flexcache/origins`

    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

  ### Inherited members

  - `Resource`:
    - `from_dict`
    - `get_collection_url`
    - `get_connection`
    - `instance_location`
    - `path_keys`
    - `poll`
    - `set_connection`
    - `to_dict`
`class FlexcacheOriginSchema (*, 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 FlexcacheOrigin object

  ### Ancestors

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

  ### Class variables

  `block_level_invalidation GET PATCH`

    Block level invalidation enables the FlexCache volume to retain blocks that are not changed at the FlexCache volume without having to evict them. This means that the FlexCache volume does not have to again incur the cost of fetching blocks over the WAN from the FlexCache volume origin on the next client access. Block level invalidation is a property of the origin volume. Without block level invalidation, any write at the origin volume would evict the whole file at the FlexCache volume, since by default, origin volume does a file level invalidation.

  `flexcaches GET POST`

    The flexcaches field of the flexcache_origin.

  `global_file_locking_enabled GET`

    Specifies whether a global file locking option is enabled for an origin volume of a FlexCache volume.

  `links GET`

    The links field of the flexcache_origin.

  `name GET POST PATCH`

    Origin volume name

    Example: vol1, vol_2

  `svm GET POST`

    The svm field of the flexcache_origin.

  `uuid GET`

    Origin volume UUID. Unique identifier for origin of FlexCache.

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