ShareLeaseClient class

Definition

Creates a new ShareLeaseClient.

This client provides lease operations on a ShareFileClient.

ShareLeaseClient(client, lease_id=None)
Inheritance
builtins.object
azure.storage.fileshare._lease.ShareLeaseClient
ShareLeaseClient

Parameters

client
ShareFileClient

The client of the file to lease.

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.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 for write and delete operations. If the file does not have an active lease, the File service creates a lease on the file. If the file has an active lease, you can only request a new lease using the active lease ID.

If the file does not have an active lease, the File service creates a lease on the file and returns a new lease ID.

break_lease

Force breaks the lease if the file 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 file. Releasing the lease allows another client to immediately acquire the lease for the file as soon as the release is complete.

The lease may be released if the client lease id specified matches that associated with the file. Releasing the lease allows another client to immediately acquire the lease for the file as soon as the release is complete.

acquire

Requests a new lease. This operation establishes and manages a lock on a file for write and delete operations. If the file does not have an active lease, the File service creates a lease on the file. If the file has an active lease, you can only request a new lease using the active lease ID.

If the file does not have an active lease, the File service creates a lease on the file and returns a new lease ID.

acquire(**kwargs)

Return type

None

break_lease

Force breaks the lease if the file 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)

Returns

Approximate time remaining in the lease period, in seconds.

Return type

int

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, **kwargs)

Parameters

proposed_lease_id
str
Required

Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is not in the correct format.

Returns

None

release

Releases the lease. The lease may be released if the lease ID specified on the request matches that associated with the file. Releasing the lease allows another client to immediately acquire the lease for the file as soon as the release is complete.

The lease may be released if the client lease id specified matches that associated with the file. Releasing the lease allows another client to immediately acquire the lease for the file as soon as the release is complete.

release(**kwargs)

Returns

None