# Module `netapp_ontap.resources.consistency_group`

Copyright © 2022 NetApp Inc. All rights reserved.

## Overview

A consistency group is a group of volumes that supports capabilities such as creating a snapshot of all of its member volumes at the same point-in-time with a write-fence, thus ensuring a consistent image of the volumes at that time.
Applications with datasets scoped to a single volume can have its contents saved to a Snapshot copy, replicated, or cloned in a crash-consistent manner implicitly with corresponding native ONTAP volume-granular operations. Applications with datasets spanning a group of multiple volumes must have such operations performed on the group. Typically, by first fencing writes to all the volumes in the group, flushing any writes pending in queues, executing the intended operation, that is, take Snapshot copy of every volume in the group and when that is complete, unfence and resume writes. A consistency group is the conventional mechanism for providing such group semantics.

## Consistency group APIs

The following APIs are used to perform operations related to consistency groups:

- GET /api/application/consistency-groups
- POST /api/application/consistency-groups
- GET /api/application/consistency-groups/{uuid}
- PATCH /api/application/consistency-groups/{uuid}
- DELETE /api/application/consistency-groups/{uuid}

## Examples

### Retrieving all consistency groups of an SVM

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="password", verify=False
    ):
        print(list(ConsistencyGroup.get_collection(**{"svm.name": "vs1"})))

Try it out

    [
        ConsistencyGroup(
            {
                "uuid": "6f48d798-0a7f-11ec-a449-005056bbcf9f",
                "name": "vol1",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/6f48d798-0a7f-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
        ConsistencyGroup(
            {
                "uuid": "c1b22c85-0a82-11ec-a449-005056bbcf9f",
                "name": "parent_cg",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b22c85-0a82-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
        ConsistencyGroup(
            {
                "uuid": "c1b270b1-0a82-11ec-a449-005056bbcf9f",
                "name": "child_1",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b270b1-0a82-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
        ConsistencyGroup(
            {
                "uuid": "c1b270c3-0a82-11ec-a449-005056bbcf9f",
                "name": "child_2",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b270c3-0a82-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
    ]

### Retrieving details of all consistency groups of an SVM

Retrieving details of the consistency groups for a specified SVM. These details are considered to be performant and will return within 1 second when 40 records or less are requested.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        print(
            list(
                ConsistencyGroup.get_collection(
                    fields="*", max_records=40, **{"svm.name": "vs1"}
                )
            )
        )

Try it out

    [
        ConsistencyGroup(
            {
                "svm": {
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"
                        }
                    },
                    "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                    "name": "vs1",
                },
                "uuid": "6f48d798-0a7f-11ec-a449-005056bbcf9f",
                "replicated": False,
                "space": {"size": 108003328, "available": 107704320, "used": 299008},
                "name": "vol1",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/6f48d798-0a7f-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
        ConsistencyGroup(
            {
                "svm": {
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"
                        }
                    },
                    "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                    "name": "vs1",
                },
                "uuid": "c1b22c85-0a82-11ec-a449-005056bbcf9f",
                "replicated": False,
                "space": {"size": 83886080, "available": 78696448, "used": 995328},
                "consistency_groups": [
                    {
                        "uuid": "c1b270b1-0a82-11ec-a449-005056bbcf9f",
                        "space": {"size": 41943040, "available": 39346176, "used": 499712},
                        "name": "child_1",
                        "_links": {
                            "self": {
                                "href": "/api/application/consistency-groups/c1b270b1-0a82-11ec-a449-005056bbcf9f"
                            }
                        },
                    },
                    {
                        "uuid": "c1b270c3-0a82-11ec-a449-005056bbcf9f",
                        "space": {"size": 41943040, "available": 39350272, "used": 495616},
                        "name": "child_2",
                        "_links": {
                            "self": {
                                "href": "/api/application/consistency-groups/c1b270c3-0a82-11ec-a449-005056bbcf9f"
                            }
                        },
                    },
                ],
                "name": "parent_cg",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b22c85-0a82-11ec-a449-005056bbcf9f"
                    }
                },
                "snapshot_policy": {
                    "uuid": "a30bd0fe-067d-11ec-a449-005056bbcf9f",
                    "name": "default-1weekly",
                    "_links": {
                        "self": {
                            "href": "/api/storage/snapshot-policies/a30bd0fe-067d-11ec-a449-005056bbcf9f"
                        }
                    },
                },
            }
        ),
        ConsistencyGroup(
            {
                "svm": {
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"
                        }
                    },
                    "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                    "name": "vs1",
                },
                "uuid": "c1b270b1-0a82-11ec-a449-005056bbcf9f",
                "space": {"size": 41943040, "available": 39346176, "used": 499712},
                "parent_consistency_group": {
                    "uuid": "c1b22c85-0a82-11ec-a449-005056bbcf9f",
                    "name": "parent_cg",
                    "_links": {
                        "self": {
                            "href": "/api/application/consistency-groups/c1b22c85-0a82-11ec-a449-005056bbcf9f"
                        }
                    },
                },
                "name": "child_1",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b270b1-0a82-11ec-a449-005056bbcf9f"
                    }
                },
                "snapshot_policy": {
                    "uuid": "a30b60a4-067d-11ec-a449-005056bbcf9f",
                    "name": "default",
                    "_links": {
                        "self": {
                            "href": "/api/storage/snapshot-policies/a30b60a4-067d-11ec-a449-005056bbcf9f"
                        }
                    },
                },
            }
        ),
        ConsistencyGroup(
            {
                "svm": {
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"
                        }
                    },
                    "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                    "name": "vs1",
                },
                "uuid": "c1b270c3-0a82-11ec-a449-005056bbcf9f",
                "space": {"size": 41943040, "available": 39350272, "used": 495616},
                "parent_consistency_group": {
                    "uuid": "c1b22c85-0a82-11ec-a449-005056bbcf9f",
                    "name": "parent_cg",
                    "_links": {
                        "self": {
                            "href": "/api/application/consistency-groups/c1b22c85-0a82-11ec-a449-005056bbcf9f"
                        }
                    },
                },
                "name": "child_2",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b270c3-0a82-11ec-a449-005056bbcf9f"
                    }
                },
                "snapshot_policy": {
                    "uuid": "a30b60a4-067d-11ec-a449-005056bbcf9f",
                    "name": "default",
                    "_links": {
                        "self": {
                            "href": "/api/storage/snapshot-policies/a30b60a4-067d-11ec-a449-005056bbcf9f"
                        }
                    },
                },
            }
        ),
    ]

### Retrieving details of non-nested consistency groups

Retrieves details of the consistency groups without nested consistency groups, or only the parent consistency group for a number of consistency groups of a specified SVM.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        print(
            list(
                ConsistencyGroup.get_collection(
                    **{"svm.name": "vs1", "parent_consistency_group.uuid": "null"}
                )
            )
        )

Try it out

    [
        ConsistencyGroup(
            {
                "svm": {"name": "vs1"},
                "uuid": "6f48d798-0a7f-11ec-a449-005056bbcf9f",
                "name": "vol1",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/6f48d798-0a7f-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
        ConsistencyGroup(
            {
                "svm": {"name": "vs1"},
                "uuid": "c1b22c85-0a82-11ec-a449-005056bbcf9f",
                "name": "parent_cg",
                "_links": {
                    "self": {
                        "href": "/api/application/consistency-groups/c1b22c85-0a82-11ec-a449-005056bbcf9f"
                    }
                },
            }
        ),
    ]

### Creating a single consistency group with a new SAN volume

Provisions an application with one consistency group, each with one new SAN volumes, with one LUN, an igroup and no explicit Snapshot copy policy, FabricPool tiering policy, storage service, and QoS policy specification. The igroup to map a LUN to is specified at LUN-granularity.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup()
        resource.svm = {"name": "vs1"}
        resource.luns = [
            {
                "name": "/vol/vol1/lun1",
                "space": {"size": "100mb"},
                "os_type": "linux",
                "lun_maps": [
                    {
                        "igroup": {
                            "name": "igroup1",
                            "initiators": [
                                {
                                    "name": "iqn.2021-07.com.netapp.englab.gdl:scspr2429998001"
                                }
                            ],
                        }
                    }
                ],
            }
        ]
        resource.post(hydrate=True)
        print(resource)

Try it out

    ConsistencyGroup(
        {
            "luns": [
                {
                    "os_type": "linux",
                    "lun_maps": [
                        {
                            "igroup": {
                                "initiators": [
                                    {
                                        "name": "iqn.2021-07.com.netapp.englab.gdl:scspr2429998001"
                                    }
                                ],
                                "name": "igroup1",
                            }
                        }
                    ],
                    "space": {"size": 104857600},
                    "name": "/vol/vol1/lun1",
                }
            ],
            "svm": {
                "_links": {
                    "self": {"href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"}
                },
                "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                "name": "vs1",
            },
            "uuid": "6f48d798-0a7f-11ec-a449-005056bbcf9f",
            "name": "vol1",
        }
    )

### Creating an Application with two consistency groups with existing SAN volumes

Provisions an application with two consistency groups, each with two existing SAN volumes, a Snapshot copy policy at application-granularity, and a distinct consistency group granular Snapshot copy policy.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup()
        resource.svm = {"name": "vs1"}
        resource.name = "parent_cg"
        resource.snapshot_policy = {"name": "default-1weekly"}
        resource.consistency_groups = [
            {
                "name": "child_1",
                "snapshot_policy": {"name": "default"},
                "volumes": [
                    {"name": "existing_vol1", "provisioning_options": {"action": "add"}},
                    {"name": "existing_vol2", "provisioning_options": {"action": "add"}},
                ],
            },
            {
                "name": "child_2",
                "snapshot_policy": {"name": "default"},
                "volumes": [
                    {"name": "existing_vol3", "provisioning_options": {"action": "add"}},
                    {"name": "existing_vol4", "provisioning_options": {"action": "add"}},
                ],
            },
        ]
        resource.post(hydrate=True)
        print(resource)

Try it out

    ConsistencyGroup(
        {
            "svm": {
                "_links": {
                    "self": {"href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"}
                },
                "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                "name": "vs1",
            },
            "uuid": "c1b22c85-0a82-11ec-a449-005056bbcf9f",
            "consistency_groups": [
                {
                    "uuid": "c1b270b1-0a82-11ec-a449-005056bbcf9f",
                    "volumes": [{"name": "existing_vol1"}, {"name": "existing_vol2"}],
                    "name": "child_1",
                    "snapshot_policy": {"name": "default"},
                },
                {
                    "uuid": "c1b270c3-0a82-11ec-a449-005056bbcf9f",
                    "volumes": [{"name": "existing_vol3"}, {"name": "existing_vol4"}],
                    "name": "child_2",
                    "snapshot_policy": {"name": "default"},
                },
            ],
            "name": "parent_cg",
            "snapshot_policy": {"name": "default-1weekly"},
        }
    )

### Retrieving specific details of an existing consistency group

Retrieves the details of an existing consistency group.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup(uuid="6f48d798-0a7f-11ec-a449-005056bbcf9f")
        resource.get()
        print(resource)

Try it out

    ConsistencyGroup(
        {
            "svm": {
                "_links": {
                    "self": {"href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"}
                },
                "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                "name": "vs1",
            },
            "uuid": "6f48d798-0a7f-11ec-a449-005056bbcf9f",
            "replicated": False,
            "space": {"size": 108003328, "available": 107724800, "used": 278528},
            "name": "vol1",
            "_links": {
                "self": {
                    "href": "/api/application/consistency-groups/6f48d798-0a7f-11ec-a449-005056bbcf9f"
                }
            },
        }
    )

### Retrieving all details of an existing consistency group

Retrieves all details of an existing consistency group. These details are not considered to be performant and are not guaranteed to return within one second.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup(uuid="6f48d798-0a7f-11ec-a449-005056bbcf9f")
        resource.get(fields="**")
        print(resource)

Try it out

    ConsistencyGroup(
        {
            "luns": [
                {
                    "os_type": "linux",
                    "lun_maps": [
                        {
                            "igroup": {
                                "os_type": "linux",
                                "initiators": [
                                    {
                                        "name": "iqn.2021-07.com.netapp.englab.gdl:scspr2429998001"
                                    }
                                ],
                                "uuid": "6f4a4b86-0a7f-11ec-a449-005056bbcf9f",
                                "protocol": "mixed",
                                "name": "igroup1",
                            },
                            "logical_unit_number": 0,
                        }
                    ],
                    "uuid": "6f51748a-0a7f-11ec-a449-005056bbcf9f",
                    "create_time": "2021-08-31T13:18:24-04:00",
                    "space": {"size": 104857600, "used": 0},
                    "name": "/vol/vol1/lun1",
                    "serial_number": "wIqM6]RfQK3t",
                }
            ],
            "svm": {
                "_links": {
                    "self": {"href": "/api/svm/svms/4853f97a-0a63-11ec-a449-005056bbcf9f"}
                },
                "uuid": "4853f97a-0a63-11ec-a449-005056bbcf9f",
                "name": "vs1",
            },
            "uuid": "6f48d798-0a7f-11ec-a449-005056bbcf9f",
            "replicated": False,
            "tiering": {"policy": "none"},
            "space": {"size": 108003328, "available": 107569152, "used": 434176},
            "volumes": [
                {
                    "uuid": "6f516c6c-0a7f-11ec-a449-005056bbcf9f",
                    "tiering": {"policy": "none"},
                    "space": {"size": 108003328, "available": 107569152, "used": 434176},
                    "comment": "",
                    "qos": {
                        "policy": {
                            "uuid": "b7189398-e572-48ab-8f69-82cd46580812",
                            "name": "extreme-fixed",
                            "_links": {
                                "self": {
                                    "href": "/api/storage/qos/policies/b7189398-e572-48ab-8f69-82cd46580812"
                                }
                            },
                        }
                    },
                    "name": "vol1",
                    "snapshot_policy": {
                        "uuid": "a30b60a4-067d-11ec-a449-005056bbcf9f",
                        "name": "default",
                    },
                }
            ],
            "qos": {
                "policy": {
                    "uuid": "b7189398-e572-48ab-8f69-82cd46580812",
                    "name": "extreme-fixed",
                    "_links": {
                        "self": {
                            "href": "/api/storage/qos/policies/b7189398-e572-48ab-8f69-82cd46580812"
                        }
                    },
                }
            },
            "name": "vol1",
            "_links": {
                "self": {
                    "href": "/api/application/consistency-groups/6f48d798-0a7f-11ec-a449-005056bbcf9f?fields=**"
                }
            },
        }
    )

### Adding LUNs to an existing volume in an existing consistency group

Adds two NVMe namespaces to an existing volume in an existing consistency group, creates a new subsystem, and binds the new namespaces to it.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup(uuid="6f48d798-0a7f-11ec-a449-005056bbcf9f")
        resource.luns = [
            {
                "name": "/vol/vol1/new_luns",
                "provisioning_options": {"count": 2, "action": "create"},
                "space": {"size": "100mb"},
                "os_type": "linux",
                "lun_maps": [
                    {
                        "igroup": {
                            "name": "igroup2",
                            "initiators": [{"name": "01:02:03:04:05:06:07:01"}],
                        }
                    }
                ],
            }
        ]
        resource.patch()

### Restoring a consistency group to the contents of an existing snapshot

Restores an existing consistency group to the contents of an existing snapshot of the consistency group.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup(uuid="6f51748a-0a7f-11ec-a449-005056bbcf9f")
        resource.restore_to = {"snapshot": {"uuid": "92c6c770-17a1-11eb-b141-005056acd498"}}
        resource.patch()

### Deleting a consistency group

Deletes a consistency group, where all storage originally associated with that consistency group remains in place.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ConsistencyGroup

    with HostConnection(
        "netapp-cluster.netapp.com", username="admin", password="netapp1!", verify=False
    ):
        resource = ConsistencyGroup(uuid="6f48d798-0a7f-11ec-a449-005056bbcf9f")
        resource.delete()

## Classes

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

  Allows interaction with ConsistencyGroup objects on the host

  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`

    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, records: Iterable[_ForwardRef('ConsistencyGroup')] = None, body: Union[Resource, dict] = None, poll: bool = True, poll_interval: Union[int, NoneType] = None, poll_timeout: Union[int, NoneType] = None, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Deletes a consistency group.
    Note this will not delete any associated volumes or LUNs. To remove those elements, you can use the appropriate object endpoint.

    ## Related ONTAP commands

    There are no ONTAP commands for managing consistency groups.

    ### Learn more

    - `DOC /application/consistency-groups`

    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.
    `records`
      Can be provided in place of a query. If so, this list of objects will be deleted from the host.
    `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.
    `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`

    Retrieve details of a collection or a specific consistency group.

    ## Notes

    When volume granular properties, such as, the storage SLC, Fabric Pool tiering are not the same for all the existing volumes of a consistency group, the corresponding property is not reported at consistency group granularity. It is only reported if all the volumes of the consistency group have the same value for that property.
    If this consistency group instance is part of a replication relationship, the "replicated" parameter will be true. Otherwise, it is false. Also, the "replicated" parameter will not be present in the output for Nested-consistency groups, it is included only for single and top-level consistency groups. If this consistency group instance is the source of a replication relationship, the "replication_source" parameter will be true. Otherwise, it is false.

    ## 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 `DOC Requesting specific fields` to learn more. * `volumes` * `luns` * `namespaces`

    ### Learn more

    - `DOC /application/consistency-groups`

    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]`

    Retrieve details of a collection or a specific consistency group.

    ## Notes

    When volume granular properties, such as, the storage SLC, Fabric Pool tiering are not the same for all the existing volumes of a consistency group, the corresponding property is not reported at consistency group granularity. It is only reported if all the volumes of the consistency group have the same value for that property.
    If this consistency group instance is part of a replication relationship, the "replicated" parameter will be true. Otherwise, it is false. Also, the "replicated" parameter will not be present in the output for Nested-consistency groups, it is included only for single and top-level consistency groups. If this consistency group instance is the source of a replication relationship, the "replication_source" parameter will be true. Otherwise, it is false.

    ## 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 `DOC Requesting specific fields` to learn more. * `volumes` * `luns` * `namespaces`

    ### Learn more

    - `DOC /application/consistency-groups`

    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, records: Iterable[_ForwardRef('ConsistencyGroup')] = None, poll: bool = True, poll_interval: Union[int, NoneType] = None, poll_timeout: Union[int, NoneType] = None, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Updates a consistency group.
    Note that this operation will never delete storage elements. You can specify only elements that should be added to the consistency group regardless of existing storage objects.

    ## Related ONTAP commands

    N/A. There are no ONTAP commands for managing consistency groups.

    ## Examples:

    ### Adding namespaces to an existing volume in an existing consistency group

    To add two NVMe Namespaces to an existing volume in an existing consistency group, create a new subsystem and bind the new namespaces to it.

        curl -X PATCH -k -u admin:netapp1! 'https://netapp-cluster.netapp.com/api/application/consistency-groups/6f51748a-0a7f-11ec-a449-005056bbcf9f' -d '{ "namespaces": [ { "name": "/vol/vol1/new_namespace", "space": { "size": "10M" }, "os_type": "windows", "provisioning_options": { "count": 2 }, "subsystem_map": { "subsystem": { "name": "mySubsystem", "hosts": [ { "nqn": "nqn.1992-08.com.netapp:sn.d04594ef915b4c73b642169e72e4c0b1:subsystem.host1" }, { "nqn": "nqn.1992-08.com.netapp:sn.d04594ef915b4c73b642169e72e4c0b1:subsystem.host2" } ] } } } ] }'
        #### Response:

    { "job": { "uuid": "8c9cabf3-0a88-11ec-a449-005056bbcf9f", "_links": { "self": { "href": "/api/cluster/jobs/8c9cabf3-0a88-11ec-a449-005056bbcf9f" } } } } ```

    ### Learn more

    - `DOC /application/consistency-groups`

    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. The body argument will be ignored if records is provided.
    `*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.
    `records`
      Can be provided in place of a query. If so, this list of objects will be patched on the host.
    `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.
    `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 post_collection(records: Iterable[_ForwardRef('ConsistencyGroup')], *args, hydrate: bool = False, poll: bool = True, poll_interval: Union[int, NoneType] = None, poll_timeout: Union[int, NoneType] = None, connection: HostConnection = None, **kwargs) -> Union[List[ConsistencyGroup], NetAppResponse]`

    Creates a consistency group with one or more consistency groups having: * new SAN volumes, * existing SAN, NVMe or NAS FlexVol volumes in a new or existing consistency group

    ## Required properties

    - `svm.uuid` or `svm.name` - Existing SVM in which to create the group.
    - `volumes`, `luns` or `namespaces`

    ## Naming Conventions

    ### Consistency groups

    - name or consistency_groups[].name, if specified
    - derived from volumes[0].name, if only one volume is specified, same as volume name

    ### Volume

    - volumes[].name, if specified
    - derived from volume prefix in luns[].name
    - derived from cg[].name, suffixed by "_#" where "#" is a system generated unique number
    - suffixed by "_#" where "#" is a system generated unique number, if provisioning_options.count is provided

    ### LUN

    - luns[].name, if specified
    - derived from volumes[].name, suffixed by "_#" where "#" is a system generated unique number
    - suffixed by "_#" where "#" is a system generated unique number, if provisioning_options.count is provided

    ### NVMe Namespace

    - namespaces[].name, if specified
    - derived from volumes[].name, suffixed by "_#" where "#" is a system generated unique number
    - suffixed by "_#" where "#" is a system generated unique number, if provisioning_options.count is provided

    ## Related ONTAP commands

    There are no ONTAP commands for managing consistency group.

    ### Learn more

    - `DOC /application/consistency-groups`

    Send this collection of objects to the host as a creation request.

    ## Args

    `records`
      A list of `Resource` objects to send to the server to be created.
    `*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 create a bar for a particular foo, the foo.name value should be passed.
    `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 each object. When hydrate is set to True, poll must also be set to True.
    `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.
    `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 list of `Resource` objects matching the provided
    `type` `which` `have` `been` `created` `by` `the` `host` `and` `returned.` `This` `is` `_not_`
    `the` `same` `list` `that` `was` `provided`, `so` `to` `continue` `using` `the` `object`, `you`

    should save this list. If poll is set to False, then a `NetAppResponse` object is returned instead.

    ## Raises

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

  ### Methods

  `def delete(self, body: Union[Resource, dict] = None, poll: bool = True, poll_interval: Union[int, NoneType] = None, poll_timeout: Union[int, NoneType] = None, **kwargs) -> NetAppResponse`

    Deletes a consistency group.
    Note this will not delete any associated volumes or LUNs. To remove those elements, you can use the appropriate object endpoint.

    ## Related ONTAP commands

    There are no ONTAP commands for managing consistency groups.

    ### Learn more

    - `DOC /application/consistency-groups`

    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 a single consistency group.

    ### 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 `DOC Requesting specific fields` to learn more. * `volumes` * `luns` * `namespaces`

    ## Related ONTAP commands

    There are no ONTAP commands for managing consistency groups.

    ### Learn more

    - `DOC /application/consistency-groups`

    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: Union[int, NoneType] = None, poll_timeout: Union[int, NoneType] = None, **kwargs) -> NetAppResponse`

    Updates a consistency group.
    Note that this operation will never delete storage elements. You can specify only elements that should be added to the consistency group regardless of existing storage objects.

    ## Related ONTAP commands

    N/A. There are no ONTAP commands for managing consistency groups.

    ## Examples:

    ### Adding namespaces to an existing volume in an existing consistency group

    To add two NVMe Namespaces to an existing volume in an existing consistency group, create a new subsystem and bind the new namespaces to it.

        curl -X PATCH -k -u admin:netapp1! 'https://netapp-cluster.netapp.com/api/application/consistency-groups/6f51748a-0a7f-11ec-a449-005056bbcf9f' -d '{ "namespaces": [ { "name": "/vol/vol1/new_namespace", "space": { "size": "10M" }, "os_type": "windows", "provisioning_options": { "count": 2 }, "subsystem_map": { "subsystem": { "name": "mySubsystem", "hosts": [ { "nqn": "nqn.1992-08.com.netapp:sn.d04594ef915b4c73b642169e72e4c0b1:subsystem.host1" }, { "nqn": "nqn.1992-08.com.netapp:sn.d04594ef915b4c73b642169e72e4c0b1:subsystem.host2" } ] } } } ] }'
        #### Response:

    { "job": { "uuid": "8c9cabf3-0a88-11ec-a449-005056bbcf9f", "_links": { "self": { "href": "/api/cluster/jobs/8c9cabf3-0a88-11ec-a449-005056bbcf9f" } } } } ```

    ### Learn more

    - `DOC /application/consistency-groups`

    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: Union[int, NoneType] = None, poll_timeout: Union[int, NoneType] = None, **kwargs) -> NetAppResponse`

    Creates a consistency group with one or more consistency groups having: * new SAN volumes, * existing SAN, NVMe or NAS FlexVol volumes in a new or existing consistency group

    ## Required properties

    - `svm.uuid` or `svm.name` - Existing SVM in which to create the group.
    - `volumes`, `luns` or `namespaces`

    ## Naming Conventions

    ### Consistency groups

    - name or consistency_groups[].name, if specified
    - derived from volumes[0].name, if only one volume is specified, same as volume name

    ### Volume

    - volumes[].name, if specified
    - derived from volume prefix in luns[].name
    - derived from cg[].name, suffixed by "_#" where "#" is a system generated unique number
    - suffixed by "_#" where "#" is a system generated unique number, if provisioning_options.count is provided

    ### LUN

    - luns[].name, if specified
    - derived from volumes[].name, suffixed by "_#" where "#" is a system generated unique number
    - suffixed by "_#" where "#" is a system generated unique number, if provisioning_options.count is provided

    ### NVMe Namespace

    - namespaces[].name, if specified
    - derived from volumes[].name, suffixed by "_#" where "#" is a system generated unique number
    - suffixed by "_#" where "#" is a system generated unique number, if provisioning_options.count is provided

    ## Related ONTAP commands

    There are no ONTAP commands for managing consistency group.

    ### Learn more

    - `DOC /application/consistency-groups`

    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 ConsistencyGroupSchema (*, 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 ConsistencyGroup object

  ### Ancestors

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

  ### Class variables

  `consistency_groups GET POST`

    A consistency group is a mutually exclusive aggregation of volumes or other consistency groups. A consistency group can only be associated with one direct parent consistency group.

  `links GET`

    The links field of the consistency_group.

  `luns GET POST PATCH`

    The LUNs array can be used to create or modify LUNs in a consistency group on a new or existing volume that is a member of the consistency group. LUNs are considered members of a consistency group if they are located on a volume that is a member of the consistency group.

  `name GET POST`

    Name of the consistency group. The consistency group name must be unique within an SVM.
    If not provided and the consistency group contains only one volume, the name will be generated based on the volume name. If the consistency group contains more than one volume, the name is required.

  `namespaces PATCH`

    An NVMe namespace is a collection of addressable logical blocks presented to hosts connected to the SVM using the NVMe over Fabrics protocol. In ONTAP, an NVMe namespace is located within a volume. Optionally, it can be located within a qtree in a volume.
    An NVMe namespace is created to a specified size using thin or thick provisioning as determined by the volume on which it is created. NVMe namespaces support being cloned. An NVMe namespace cannot be renamed, resized, or moved to a different volume. NVMe namespaces do not support the assignment of a QoS policy for performance management, but a QoS policy can be assigned to the volume containing the namespace. See the NVMe namespace object model to learn more about each of the properties supported by the NVMe namespace REST API.
    An NVMe namespace must be mapped to an NVMe subsystem to grant access to the subsystem's hosts. Hosts can then access the NVMe namespace and perform I/O using the NVMe over Fabrics protocol.

  `parent_consistency_group GET POST PATCH`

    The parent_consistency_group field of the consistency_group.

  `provisioning_options GET POST PATCH`

    The provisioning_options field of the consistency_group.

  `qos GET POST PATCH`

    The qos field of the consistency_group.

  `replicated GET`

    Indicates whether or not replication has been enabled on this consistency group.

  `replication_source GET`

    Indicates whether or not this consistency group is the source for replication.

  `restore_to PATCH`

    The restore_to field of the consistency_group.

  `snapshot_policy GET POST PATCH`

    The Snapshot copy policy of the consistency group.
    This is the dedicated consistency group Snapshot copy policy, not an aggregation of the volume granular Snapshot copy policy.

  `space GET POST PATCH`

    The space field of the consistency_group.

  `svm GET POST PATCH`

    The Storage Virtual Machine (SVM) in which the consistency group is located.

  `tiering GET POST`

    The tiering field of the consistency_group.

  `uuid GET`

    The unique identifier of the consistency group. The UUID is generated by ONTAP when the consistency group is created.

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

  `volumes GET POST`

    A consistency group is a mutually exclusive aggregation of volumes or other consistency groups. A volume can only be associated with one direct parent consistency group.
    The volumes array can be used to create new volumes in the consistency group, add existing volumes to the consistency group, or modify existing volumes that are already members of the consistency group.
    The total number of volumes across all child consistency groups contained in a consistency group is constrained by the same limit.