# Module `netapp_ontap.resources.mediator`

Copyright © 2021 NetApp Inc. All rights reserved.

## Overview

You can use this API to add or remove a mediator to MetroCluster over IP configuration, or get the status and details of the existing mediator in MetroCluster over IP configuration. The GET operation returns the status of the mediator along with the mediator details. The DELETE operation removes the mediator. The POST operation adds the mediator.

## Adding a mediator

A mediator can be added to MetroCluster over IP configuration by issuing a POST on /cluster/mediators. Parameters are provided in the body of the POST request. There are no optional parameters for adding a mediator.

### Required configuration fields

These fields are always required for any POST /cluster/mediators request.

- `ip_address` - Specifies the IP address of the mediator.
- `user` - Specifies a user name credential.
- `password` - Specifies a password credential.

### Polling the setup job

After a successful POST /cluster/mediators is issued, an HTTP status code of 202 (Accepted) is returned along with a job UUID and a link in the body of the response. The setup job continues asynchronously and can be monitored by using the job UUID and the /cluster/jobs API. The "message" field in the response of the GET /cluster/jobs/{uuid} request shows the current step in the job, and the "state" field shows the overall state of the job.

## Deleting a Mediator

A mediator can be deleted from MetroCluster over IP configuration by issuing a DELETE to /cluster/mediators/{uuid}. Parameters are provided in the body of the DELETE request. There are no optional parameters for adding a mediator.

### Required configuration fields

These fields are always required for any DELETE /cluster/mediators/{uuid} request.

- `user` - Specifies a user name credential.
- `password` - Specifies a password credential.

### Polling the delete job

After a successful DELETE /cluster/mediators/{uuid} is issued, an HTTP status code of 202 (Accepted) is returned along with a job UUID and a link in the body of the response. The delete job continues asynchronously and can be monitored by using the job UUID and the /cluster/jobs API. The "message" field in the response of the GET /cluster/jobs/{uuid} request shows the current step in the job, and the "state" field shows the overall state of the job.

## Examples

### Setting up a mediator for a 4-Node MetroCluster over IP Configuration

This example shows the POST body when setting up a mediator for a 4-Node MetroCluster over IP configuration. The only prerequisite is that MetroCluster over IP is configured.

    # API
    /api/cluster/mediators

### POST body included from file

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Mediator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Mediator()
        resource.ip_address = "1.1.1.1"
        resource.user = "username"
        resource.password = "password"
        resource.post(hydrate=True)
        print(resource)

### Inline POST body

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Mediator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Mediator()
        resource.ip_address = "1.1.1.1"
        resource.user = "username"
        resource.password = "password"
        resource.post(hydrate=True)
        print(resource)

### POST Response

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 07:40:59 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 189
    Content-Type: application/hal+json
    {
      "job": {
        "uuid": "f567b48b-fca6-11ea-acaf-005056bb47c1",
        "_links": {
          "self": {
            "href": "/api/cluster/jobs/f567b48b-fca6-11ea-acaf-005056bb47c1"
          }
        }
      }
    }

### Monitoring the job progress

Use the link provided in the response to the POST request to fetch information for the mediator setup job.

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Job

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Job(uuid="f567b48b-fca6-11ea-acaf-005056bb47c1")
        resource.get()
        print(resource)

#### Job status response

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 07:41:29 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 189
    Content-Type: application/hal+json
    {
      "uuid": "f567b48b-fca6-11ea-acaf-005056bb47c1",
      "description": "POST /api/cluster/mediators/",
      "state": "running",
      "start_time": "2020-09-22T03:41:00-04:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/f567b48b-fca6-11ea-acaf-005056bb47c1"
        }
      }
    }

#### Final status of a successful Mediator add

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 07:43:38 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 358
    Content-Type: application/hal+json
    {
      "uuid": "f567b48b-fca6-11ea-acaf-005056bb47c1",
      "description": "POST /api/cluster/mediators/",
      "state": "success",
      "message": "success",
      "code": 0,
      "start_time": "2020-09-22T03:41:00-04:00",
      "end_time": "2020-09-22T03:42:10-04:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/f567b48b-fca6-11ea-acaf-005056bb47c1"
        }
      }
    }

### Retrieving the existing mediator configurations

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Mediator

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

#### Response

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 08:53:18 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 320
    Content-Type: application/hal+json
    {
      "records": [
        {
          "uuid": "f89e8906-fca6-11ea-acaf-005056bb47c1",
          "_links": {
            "self": {
              "href": "/api/cluster/mediators/f89e8906-fca6-11ea-acaf-005056bb47c1"
            }
          }
        }
      ],
      "num_records": 1,
      "_links": {
        "self": {
          "href": "/api/cluster/mediators"
        }
      }
    }

### Retrieving a specific mediator using the uuid

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Mediator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Mediator(uuid="f89e8906-fca6-11ea-acaf-005056bb47c1")
        resource.get()
        print(resource)

#### Response

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 08:59:40 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 347
    Content-Type: application/hal+json
    {
      "uuid": "f89e8906-fca6-11ea-acaf-005056bb47c1",
      "ip_address": "10.234.173.40",
      "port": 31784,
      "reachable": true,
      "peer_cluster": {
        "name": "mcc_siteB",
        "uuid": "38779fd1-fc6b-11ea-9421-005056bb21d8"
      },
      "_links": {
        "self": {
          "href": "/api/cluster/mediators/f89e8906-fca6-11ea-acaf-005056bb47c1"
        }
      }
    }

### Deleting a configured Mediator using the uuid

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Mediator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Mediator(uuid="{uuid}")
        resource.delete(body={"user": "username", "password": "password"})

#### Response

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 09:13:52 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 189
    Content-Type: application/hal+json
    {
      "job": {
        "uuid": "eeb71ccd-fcb3-11ea-acaf-005056bb47c1",
        "_links": {
          "self": {
            "href": "/api/cluster/jobs/eeb71ccd-fcb3-11ea-acaf-005056bb47c1"
          }
        }
      }
    }

### Monitoring the job progress

Use the link provided in the response to the DELETE request to fetch information for the delete job.

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Job

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Job(uuid="eeb71ccd-fcb3-11ea-acaf-005056bb47c1")
        resource.get()
        print(resource)

#### Job status response

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 09:14:20 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 316
    Content-Type: application/hal+json
    {
      "uuid": "eeb71ccd-fcb3-11ea-acaf-005056bb47c1",
      "description": "DELETE /api/cluster/mediators/f89e8906-fca6-11ea-acaf-005056bb47c1",
      "state": "running",
      "start_time": "2020-09-22T05:13:52-04:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/eeb71ccd-fcb3-11ea-acaf-005056bb47c1"
        }
      }
    }

#### Final status of the Mediator DELETE job

    HTTP/1.1 202 Accepted
    Date: Tue, 22 Sep 2020 09:21:46 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 396
    Content-Type: application/hal+json
    {
      "uuid": "eeb71ccd-fcb3-11ea-acaf-005056bb47c1",
      "description": "DELETE /api/cluster/mediators/f89e8906-fca6-11ea-acaf-005056bb47c1",
      "state": "success",
      "message": "success",
      "code": 0,
      "start_time": "2020-09-22T05:13:52-04:00",
      "end_time": "2020-09-22T05:14:24-04:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/eeb71ccd-fcb3-11ea-acaf-005056bb47c1"
        }
      }
    }

## Classes

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

  Mediator information

  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 mediators configured in the cluster.

    ### Learn more

    - `DOC /cluster/mediators`

    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 the mediator.

    ### Learn more

    - `DOC /cluster/mediators`

    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 deleted.

    ## 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 mediators configured in the cluster.

    ### Learn more

    - `DOC /cluster/mediators`

    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 mediators configured in the cluster.

    ### Learn more

    - `DOC /cluster/mediators`

    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.

  ### Methods

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

    Deletes the mediator.

    ### Learn more

    - `DOC /cluster/mediators`

    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 the mediator state and configuration.

    ### Learn more

    - `DOC /cluster/mediators`

    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 post(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Creates and connect a mediator.

    ### Learn more

    - `DOC /cluster/mediators`

    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 MediatorSchema (*, 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 Mediator object

  ### Ancestors

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

  ### Class variables

  `ca_certificate POST`

    CA certificate for ONTAP Mediator. This is optional if the certificate is already installed.

  `dr_group`

    The dr_group field of the mediator.

  `ip_address GET POST`

    The IP address of the mediator.

    Example: 10.10.10.7

  `password POST`

    The password used to connect to the REST server on the mediator.

    Example: mypassword

  `peer_cluster GET POST`

    The peer_cluster field of the mediator.

  `port GET POST`

    The REST server's port number on the mediator.

    Example: 31784

  `reachable GET`

    Indicates the connectivity status of the mediator.

    Example: true

  `user POST`

    The username used to connect to the REST server on the mediator.

    Example: myusername

  `uuid GET`

    The unique identifier for the mediator service.