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

# Module `netapp_ontap.resources.client_lock`

Copyright © 2026 NetApp Inc. All rights reserved.

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

## Overview

A lock is a synchronization mechanism for enforcing limits on concurrent access to files where many clients can be accessing the same file at the same time. Locks can be viewed or broken according to a wide range of query fields that are presented in the lock information definition.
It is recommended that you provide as many fields as possible to optimize query processing.

## Examples

### Retrieving locks with all fields for all SVMs

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClientLock

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(ClientLock.get_collection(return_timeout=15, fields="*")))

Try it out

    [
        ClientLock(
            {
                "protocol": "cifs",
                "client_address": "10.74.7.22",
                "interface": {
                    "ip": {"address": "10.140.115.95"},
                    "name": "vs1.data",
                    "uuid": "6bf26e25-9ae4-11eb-8597-0050568ec154",
                },
                "share_lock": {"mode": "read_write_deny_write_delete", "soft": False},
                "state": "granted",
                "volume": {
                    "name": "test_vol1",
                    "uuid": "429dcc79-9af2-11eb-b313-0050568ec154",
                },
                "uuid": "bf03d8b4-e145-498a-902d-b9fe5d546d18",
                "constituent": False,
                "smb": {
                    "open_type": "durable",
                    "open_group_id": "71756e2325a7eb11843f005056a4731c101068450bcdffff1c2c000000000000",
                    "connect_state": "connected",
                },
                "path": "/test_vol1/Demo406.TXT",
                "type": "share_level",
                "node": {
                    "name": "user-vsim3",
                    "uuid": "1f29b875-9ae3-11eb-8597-0050568ec154",
                },
                "owner_id": "feff-0206000000020000000204000000000000000000000000ffff0a4a07161053010001000000030000006c00000000000000",
                "svm": {"name": "vs1", "uuid": "5b4b6847-9ae4-11eb-8597-0050568ec154"},
            }
        ),
        ClientLock(
            {
                "protocol": "cifs",
                "client_address": "10.74.7.22",
                "interface": {
                    "ip": {"address": "10.140.115.95"},
                    "name": "vs1.data",
                    "uuid": "6bf26e25-9ae4-11eb-8597-0050568ec154",
                },
                "state": "granted",
                "volume": {
                    "name": "test_vol1",
                    "uuid": "429dcc79-9af2-11eb-b313-0050568ec154",
                },
                "uuid": "0c33d18d-dcbc-492a-81b3-4c5740c46172",
                "constituent": False,
                "smb": {
                    "open_group_id": "71756e2325a7eb11843f005056a4731c101068450bcdffff1c2c000000000000",
                    "connect_state": "connected",
                },
                "oplock_level": "batch",
                "path": "/test_vol1/Demo406.TXT",
                "type": "op_lock",
                "node": {
                    "name": "user-vsim3",
                    "uuid": "1f29b875-9ae3-11eb-8597-0050568ec154",
                },
                "owner_id": "feff-0206000000020000000204000000000000000000000000ffff0a4a07161053010001000000030000006c00000000000000",
                "svm": {"name": "vs1", "uuid": "5b4b6847-9ae4-11eb-8597-0050568ec154"},
            }
        ),
    ]

### Retrieving locks of a specific volume

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClientLock

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(
            list(
                ClientLock.get_collection(
                    return_timeout=15,
                    fields="*",
                    **{"volume.uuid": "429dcc79-9af2-11eb-b313-0050568ec154"}
                )
            )
        )

Try it out

    [
        ClientLock(
            {
                "interface": {
                    "name": "vs1.data",
                    "uuid": "6bf26e25-9ae4-11eb-8597-0050568ec154",
                },
                "volume": {
                    "name": "test_vol1",
                    "uuid": "429dcc79-9af2-11eb-b313-0050568ec154",
                },
                "uuid": "be1cdf00-37f1-4477-b6d0-bba8c4fa8c67",
                "path": "/test_vol1/Demo408.TXT",
                "svm": {"name": "vs1", "uuid": "5b4b6847-9ae4-11eb-8597-0050568ec154"},
            }
        ),
        ClientLock(
            {
                "interface": {
                    "name": "vs1.data",
                    "uuid": "6bf26e25-9ae4-11eb-8597-0050568ec154",
                },
                "volume": {
                    "name": "test_vol1",
                    "uuid": "429dcc79-9af2-11eb-b313-0050568ec154",
                },
                "uuid": "393cc06e-8b37-4f49-b09a-74d1eef79368",
                "path": "/test_vol1/Demo408.TXT",
                "svm": {"name": "vs1", "uuid": "5b4b6847-9ae4-11eb-8597-0050568ec154"},
            }
        ),
    ]

### Retrieving the lock for a specific UUID

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClientLock

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClientLock(uuid="be1cdf00-37f1-4477-b6d0-bba8c4fa8c67")
        resource.get()
        print(resource)

Try it out

    ClientLock(
        {
            "protocol": "cifs",
            "client_address": "10.74.7.22",
            "interface": {
                "ip": {"address": "10.140.115.95"},
                "name": "vs1.data",
                "uuid": "6bf26e25-9ae4-11eb-8597-0050568ec154",
            },
            "share_lock": {"mode": "read_write_deny_write_delete", "soft": False},
            "state": "granted",
            "volume": {"name": "test_vol1", "uuid": "429dcc79-9af2-11eb-b313-0050568ec154"},
            "uuid": "be1cdf00-37f1-4477-b6d0-bba8c4fa8c67",
            "constituent": False,
            "smb": {
                "open_type": "durable",
                "open_group_id": "71756e2325a7eb11843f005056a4731c101068450bcdffff1c2c000000000000",
                "connect_state": "connected",
            },
            "path": "/test_vol1/Demo406.TXT",
            "type": "share_level",
            "node": {"name": "user-vsim3", "uuid": "1f29b875-9ae3-11eb-8597-0050568ec154"},
            "owner_id": "feff-0206000000020000000204000000000000000000000000ffff0a4a07161053010001000000030000006c00000000000000",
            "svm": {"name": "vs1", "uuid": "5b4b6847-9ae4-11eb-8597-0050568ec154"},
        }
    )

### Deleting the lock for a specific UUID

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClientLock

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClientLock(uuid="be1cdf00-37f1-4477-b6d0-bba8c4fa8c67")
        resource.delete()

### Deleting all locks for a specific protocol

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClientLock

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClientLock()
        resource.delete(protocol="cifs")

## Classes

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

  This object represents locks on a volume.

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

    Deletes locks of given parameter.

    ### Related ONTAP commands

    - `vserver locks break`

    ### Learn more

    - `DOC /protocols/locks`

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

    Returns a list of RawResources that represent ClientLock 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 locks details.

    ### Related ONTAP commands

    - `vserver locks show`

    ### Learn more

    - `DOC /protocols/locks`

    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 locks details.

    ### Related ONTAP commands

    - `vserver locks show`

    ### Learn more

    - `DOC /protocols/locks`

    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 delete (self, body: Union[Resource, dict] = None, poll: bool = True, poll_interval: Optional[int] = None, poll_timeout: Optional[int] = None, **kwargs) -> NetAppResponse`

    Deletes locks of given parameter.

    ### Related ONTAP commands

    - `vserver locks break`

    ### Learn more

    - `DOC /protocols/locks`

    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.
    `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 `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 lock for a specific UUID.

    ### Related ONTAP commands

    - `vserver locks show`

    ### Learn more

    - `DOC /protocols/locks`

    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 or if not all of the keys required are present and config.STRICT_GET has been set to True.

  ### Inherited members

  - `Resource`:
    - `from_dict`
    - `get_collection_url`
    - `get_connection`
    - `instance_location`
    - `path_keys`
    - `poll`
    - `set_connection`
    - `to_dict`
    - `validate_schema`
`class ClientLockSchema (*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool | None = None, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet | None = None, unknown: str | None = None)`

  The fields of the ClientLock object

  ### Ancestors

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

  ### Class variables

  `byte_lock: ByteLock GET POST PATCH`

    The byte_lock field of the client_lock.

  `client_address: str GET POST PATCH`

    IP address of the client holding the lock.

    Example: 0.0.0.0

  `constituent: bool GET`

    Indicate if volume is constituent or not.

  `delegation: str GET`

    Type of delegation.

    Valid choices:

    - read
    - write
  `interface: IpInterface GET POST PATCH`

    The interface field of the client_lock.

  `node: Node GET POST PATCH`

    The node field of the client_lock.

  `oplock_level: str GET`

    The oplock level determines which operations the client may cache locally.

    Valid choices:

    - exclusive
    - level2
    - batch
    - null
    - read_batch
  `owner_id: str GET`

    Owner ID.

  `path: str GET POST PATCH`

    Object path

  `protocol: str GET POST PATCH`

    Type of lock protocol.

    Valid choices:

    - cifs
    - fcache
    - nfsv4
    - http
    - nlm
    - nfsv4.1
    - crposix
  `share_lock: ShareLock GET POST PATCH`

    The share_lock field of the client_lock.

  `smb: Smb GET POST PATCH`

    The smb field of the client_lock.

  `state: str GET`

    State of lock.

    Valid choices:

    - granted
    - revoking
    - adjusted
    - denied
    - subsumed
    - gone
    - unused
    - waiting
    - timeout
  `svm: Svm GET POST PATCH`

    The svm field of the client_lock.

  `type: str GET`

    Type of lock.

    Valid choices:

    - byte_range
    - share_level
    - op_lock
    - delegation
  `uuid: str GET POST PATCH`

    Lock UUID

    Example: ceeac1b4-8646-4c76-a054-1c96e87594aa

  `volume: Volume GET POST PATCH`

    The volume field of the client_lock.