ShareLeaseClient Class
Creates a new ShareLeaseClient.
This client provides lease operations on a ShareClient or ShareFileClient.
- Inheritance
-
builtins.objectShareLeaseClient
Constructor
ShareLeaseClient(client: ShareFileClient | ShareClient, lease_id: str | None = None)
Parameters
Name | Description |
---|---|
client
Required
|
The client of the file or share to lease. |
lease_id
|
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. Default value: None
|
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
Keyword-Only Parameters
Name | Description |
---|---|
lease_duration
|
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
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
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
Keyword-Only Parameters
Name | Description |
---|---|
lease_break_period
|
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
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
Approximate time remaining in the lease period, in seconds. |
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
Name | Description |
---|---|
proposed_lease_id
Required
|
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. |
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
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
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
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
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
None |
Attributes
etag
The ETag of the lease currently being maintained. This will be None if no lease has yet been acquired or modified.
etag: str | None
id
The ID of the lease currently being maintained. This will be None if no lease has yet been acquired.
id: str
last_modified
The last modified timestamp of the lease currently being maintained. This will be None if no lease has yet been acquired or modified.
last_modified: datetime | None
Azure SDK for Python