ShareLeaseClient Class
Creates a new ShareLeaseClient.
This client provides lease operations on a ShareClient or ShareFileClient.
- Inheritance
-
builtins.objectShareLeaseClient
Constructor
ShareLeaseClient(client: Union[ShareFileClient, ShareClient], lease_id: Optional[str] = None)
Parameters
- lease_id
- str
A string representing the lease ID of an existing lease. This value does not need to be specified in order to acquire a new lease, or break one.
Variables
- id
- str
The ID of the lease currently being maintained. This will be None if no lease has yet been acquired.
- etag
- str
The ETag of the lease currently being maintained. This will be None if no lease has yet been acquired or modified.
- last_modified
- datetime
The last modified timestamp of the lease currently being maintained. This will be None if no lease has yet been acquired or modified.
Methods
| acquire |
Requests a new lease. This operation establishes and manages a lock on a file or share for write and delete operations. If the file or share does not have an active lease, the File or Share service creates a lease on the file or share. If the file has an active lease, you can only request a new lease using the active lease ID. If the file or share does not have an active lease, the File or Share service creates a lease on the file and returns a new lease ID. |
| break_lease |
Force breaks the lease if the file or share has an active lease. Any authorized request can break the lease; the request is not required to specify a matching lease ID. An infinite lease breaks immediately. Once a lease is broken, it cannot be changed. Any authorized request can break the lease; the request is not required to specify a matching lease ID. When a lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired. |
| change |
Changes the lease ID of an active lease. A change must include the current lease ID in x-ms-lease-id and a new lease ID in x-ms-proposed-lease-id. |
| release |
Releases the lease. The lease may be released if the lease ID specified on the request matches that associated with the share or file. Releasing the lease allows another client to immediately acquire the lease for the share or file as soon as the release is complete. |
| renew |
Renews the share lease. The share lease can be renewed if the lease ID specified in the lease client matches that associated with the share. Note that the lease may be renewed even if it has expired as long as the share has not been leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets. New in version 12.6.0. |
acquire
Requests a new lease. This operation establishes and manages a lock on a file or share for write and delete operations. If the file or share does not have an active lease, the File or Share service creates a lease on the file or share. If the file has an active lease, you can only request a new lease using the active lease ID.
If the file or share does not have an active lease, the File or Share service creates a lease on the file and returns a new lease ID.
acquire(**kwargs: Any) -> None
Parameters
- lease_duration
- int
Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. File leases never expire. A non-infinite share lease can be between 15 and 60 seconds. A share lease duration cannot be changed using renew or change. Default is -1 (infinite share lease).
- timeout
- int
The timeout parameter is expressed in seconds.
Return type
break_lease
Force breaks the lease if the file or share has an active lease. Any authorized request can break the lease; the request is not required to specify a matching lease ID. An infinite lease breaks immediately.
Once a lease is broken, it cannot be changed. Any authorized request can break the lease; the request is not required to specify a matching lease ID. When a lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired.
break_lease(**kwargs: Any) -> int
Parameters
- lease_break_period
- int
This is the proposed duration of seconds that the share lease should continue before it is broken, between 0 and 60 seconds. This break period is only used if it is shorter than the time remaining on the share lease. If longer, the time remaining on the share lease is used. A new share lease will not be available before the break period has expired, but the share lease may be held for longer than the break period. If this header does not appear with a break operation, a fixed-duration share lease breaks after the remaining share lease period elapses, and an infinite share lease breaks immediately.
New in version 12.6.0.
- timeout
- int
The timeout parameter is expressed in seconds.
Returns
Approximate time remaining in the lease period, in seconds.
Return type
change
Changes the lease ID of an active lease. A change must include the current lease ID in x-ms-lease-id and a new lease ID in x-ms-proposed-lease-id.
change(proposed_lease_id: str, **kwargs: Any) -> None
Parameters
- proposed_lease_id
- str
Proposed lease ID, in a GUID string format. The File or Share service will raise an error (Invalid request) if the proposed lease ID is not in the correct format.
- timeout
- int
The timeout parameter is expressed in seconds.
Returns
None
release
Releases the lease. The lease may be released if the lease ID specified on the request matches that associated with the share or file. Releasing the lease allows another client to immediately acquire the lease for the share or file as soon as the release is complete.
release(**kwargs: Any) -> None
Parameters
- timeout
- int
The timeout parameter is expressed in seconds.
Returns
None
renew
Renews the share lease.
The share lease can be renewed if the lease ID specified in the lease client matches that associated with the share. Note that the lease may be renewed even if it has expired as long as the share has not been leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets.
New in version 12.6.0.
renew(**kwargs: Any) -> None
Parameters
- timeout
- int
The timeout parameter is expressed in seconds.
Returns
None
Feedback
Submit and view feedback for