# Module `netapp_ontap.resources.fabric`

Copyright © 2023 NetApp Inc. All rights reserved.

This file has been automatically generated based on the ONTAP REST API documentation.

## Overview

The Fibre Channel (FC) fabric REST APIs provide read-only access to FC network information. This includes:

- the connections between the ONTAP cluster and the FC fabric,
- the switches that comprise the fabric, and
- the zones of the active zoneset of the fabric.

## Caching

Obtaining this information from the FC fabric can be time consuming. To allow the REST API to be more responsive, the APIs always return data from a cache that is updated asynchronously, but only on demand. Cache updates are triggered when the age of cached data exceeds the caller-specified maximum age as specified by the query parameter `cache.maximum_age`. When a GET request initiates a cache refresh, the API attempts to wait for the update to complete before returning. If the cache cannot be updated before the return timeout (see query parameter `return_timeout`), the GET returns the currently cached data, but the cache update continues asynchronously. The caller may examine the returned property `cache.update_time` or `cache.age` to determine if the returned information is sufficiently fresh. If not, the caller should wait several seconds, then make a GET request again until the returned information is updated.

## Examples

Fibre Channel fabric data is typically large. The numbers of rows returned in the following examples has been edited to simplify reading.

### Retrieving the Fibre Channel fabrics to which the cluster is connected

This example retrieves the names of the cluster's connected Fibre Channel fabrics. It also retrieves the cache timestamp properties so that the caller can verify the currency of the data.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Fabric

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

Try it out

    [
        Fabric(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:21:29+00:00",
                    "age": "PT1M16S",
                },
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10%3A00%3Aaa%3Abb%3Acc%3Add%3Aee%3Aff"
                    }
                },
                "name": "10:00:aa:bb:cc:dd:ee:ff",
            }
        ),
        Fabric(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:21:29+00:00",
                    "age": "PT1M16S",
                },
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10%3A00%3Aff%3Aee%3Add%3Acc%3Abb%3Aaa"
                    }
                },
                "name": "10:00:ff:ee:dd:cc:bb:aa",
            }
        ),
    ]

### Retrieving all switches of a Fibre Channel fabric

This example retrieves the switches of Fibre Channel fabric `10:00:aa:bb:cc:dd:ee:ff`.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcSwitch

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(FcSwitch.get_collection("10:00:aa:bb:cc:dd:ee:ff", fields="cache")))

Try it out

    [
        FcSwitch(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:22:00+00:00",
                    "age": "PT45S",
                },
                "wwn": "10:00:1a:1b:1c:1d:1e:1f",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/switches/10:00:1a:1b:1c:1d:1e:1f"
                    }
                },
            }
        ),
        FcSwitch(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:22:00+00:00",
                    "age": "PT45S",
                },
                "wwn": "10:00:2a:2b:2c:2d:2e:1f",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/switches/10:00:2a:2b:2c:2d:2e:1f"
                    }
                },
            }
        ),
        FcSwitch(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:22:00+00:00",
                    "age": "PT45S",
                },
                "wwn": "10:00:3a:3b:3c:3d:3e:3f",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/switches/10:00:3a:3b:3c:3d:3e:3f"
                    }
                },
            }
        ),
        FcSwitch(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:22:00+00:00",
                    "age": "PT45S",
                },
                "wwn": "10:00:4a:4b:4c:4d:4e:4f",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/switches/10:00:4a:4b:4c:4d:4e:4f"
                    }
                },
            }
        ),
        FcSwitch(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:22:00+00:00",
                    "age": "PT45S",
                },
                "wwn": "10:00:5a:5b:1a:5c:5d:5e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/switches/10:00:5a:5b:1a:5c:5d:5e"
                    }
                },
            }
        ),
    ]

### Retrieving all zones of the active zoneset of a Fibre Channel fabric

This example retrieves the zone of the active set of Fibre Channel fabric `10:00:aa:bb:cc:dd:ee:ff`.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcZone

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(FcZone.get_collection("10:00:aa:bb:cc:dd:ee:ff", fields="cache")))

Try it out

    [
        FcZone(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T20:17:06+00:00",
                    "age": "PT1H17M54S",
                },
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/zones/zone1"
                    }
                },
                "name": "zone1",
            }
        ),
        FcZone(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T20:17:06+00:00",
                    "age": "PT1H17M54S",
                },
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/zones/zone2"
                    }
                },
                "name": "zone2",
            }
        ),
        FcZone(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T20:17:06+00:00",
                    "age": "PT1H17M54S",
                },
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/zones/zone3"
                    }
                },
                "name": "zone3",
            }
        ),
        FcZone(
            {
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T20:17:06+00:00",
                    "age": "PT1H17M54S",
                },
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/zones/zone4"
                    }
                },
                "name": "zone4",
            }
        ),
    ]

### Searching all Fibre Channel fabrics for a specific attached device identified by its WWPN

This example finds the Fibre Channel fabric, switch, and switch port to which the device with WWPN `50:0a:2a:2b:2c:2d:2e:2f` is attached. Note the use of the wildcard character in place of a fabric WWN in order to search all Fibre Channel fabrics.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcSwitch

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(
            list(
                FcSwitch.get_collection(
                    "*",
                    fields="ports,cache",
                    **{"ports.attached_device.wwpn": "50:0a:2a:2b:2c:2d:2e:2f"}
                )
            )
        )

Try it out

    [
        FcSwitch(
            {
                "ports": [
                    {
                        "wwpn": "20:00:1a:1b:1c:1d:1e:1f",
                        "attached_device": {
                            "wwpn": "50:0a:1a:1b:1c:1d:1e:1f",
                            "port_id": "0x999000",
                        },
                        "state": "online",
                        "type": "f_port",
                        "slot": "0",
                    },
                    {
                        "wwpn": "20:01:2a:2b:1c:2d:2e:2f",
                        "attached_device": {
                            "wwpn": "50:0a:2a:2b:2c:2d:2e:2f",
                            "port_id": "0x999100",
                        },
                        "state": "online",
                        "type": "f_port",
                        "slot": "1",
                    },
                    {
                        "wwpn": "20:02:3a:3b:3c:3d:3e:3f",
                        "state": "offline",
                        "type": "none",
                        "slot": "2",
                    },
                    {
                        "wwpn": "20:03:4a:4b:4c:4d:4e:4f",
                        "attached_device": {
                            "wwpn": "50:0a:4a:4b:4c:4d:4e:4f",
                            "port_id": "0x999300",
                        },
                        "state": "offline",
                        "type": "f_port",
                        "slot": "3",
                    },
                    {
                        "wwpn": "20:04:5a:5b:5c:5d:5e:5f",
                        "attached_device": {
                            "wwpn": "50:0a:5a:5b:5c:5d:5e:5f",
                            "port_id": "0x999400",
                        },
                        "state": "online",
                        "type": "f_port",
                        "slot": "4",
                    },
                ],
                "cache": {
                    "is_current": True,
                    "update_time": "2022-02-07T21:57:29+00:00",
                    "age": "PT4M49S",
                },
                "wwn": "10:00:6a:6b:6c:6d:6e:6f",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/fabrics/10:00:aa:bb:cc:dd:ee:ff/switches/10:00:6a:6b:6c:6d:6e:6f"
                    }
                },
                "fabric": {
                    "_links": {
                        "self": {
                            "href": "/api/network/fc/fabrics/10%3A00%3Aaa%3Abb%3Acc%3Add%3Aee%3Aff"
                        }
                    },
                    "name": "10:00:aa:bb:cc:dd:ee:ff",
                },
            }
        )
    ]

## Classes

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

  A Fibre Channel (FC) fabric REST object provides information about an FC network (fabric) connected to the cluster. Logically, the FC fabric also contains FC switches and the FC zones that comprise the active zoneset of the fabric. FC switch and zone information is not reported directly in the FC fabric REST object for reasons of scale and flexibility; they are found by querying the FC switches and FC zones REST endpoints.

  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`

    Returns a count of all Fabric resources that match the provided query

    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 fast_get_collection (*args, connection: HostConnection = None, max_records: int = None, **kwargs) -> Iterable[RawResource]`

    Returns a list of RawResources that represent Fabric resources that match the provided query

    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
    `raw`
      return a list of `netapp_ontap.resource.RawResource` objects that require to be promoted before any RESTful operations can be used on them. Setting this argument to True makes get_collection substantially quicker when many records are returned from the server.
    `**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 find (*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves Fibre Channel fabrics.

    ### Expensive properties

    There is an added computational 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. * `connections` * `zoneset`

    ### Related ONTAP commands

    - `network fcp topology show`
    - `network fcp zone show`

    ### Learn more

    - `DOC /network/fc/fabrics`

    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) -> Iterable[Resource]`

    Retrieves Fibre Channel fabrics.

    ### Expensive properties

    There is an added computational 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. * `connections` * `zoneset`

    ### Related ONTAP commands

    - `network fcp topology show`
    - `network fcp zone show`

    ### Learn more

    - `DOC /network/fc/fabrics`

    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
    `raw`
      return a list of `netapp_ontap.resource.RawResource` objects that require to be promoted before any RESTful operations can be used on them. Setting this argument to True makes get_collection substantially quicker when many records are returned from the server.
    `**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.

  ### Methods

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

    Retrieves a Fibre Channel fabric.

    ### Expensive properties

    There is an added computational 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. * `connections` * `zoneset`

    ### Related ONTAP commands

    - `network fcp topology show`
    - `network fcp zone show`

    ### Learn more

    - `DOC /network/fc/fabrics`

    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

  ### Inherited members

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

  The fields of the Fabric object

  ### Ancestors

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

  ### Class variables

  `cache: FabricCache GET`

    The cache field of the fabric.

  `connections: List[FabricConnections] GET`

    An array of the connections between the cluster and the switches Fibre Channel fabric.

  `links: SelfLink GET`

    The links field of the fabric.

  `name: str GET`

    The world wide name (WWN) of the primary switch of the Fibre Channel (FC) fabric. This is used as a unique identifier for the FC fabric.

    Example: 10:00:c1:c2:c3:c4:c5:c6

  `zoneset: FabricZoneset GET`

    The zoneset field of the fabric.