Class ShareLeaseClient
java.lang.Object
com.azure.storage.file.share.specialized.ShareLeaseClient
This class provides a client that contains all the leasing operations for
files
.
This client acts as a supplement to that client and only handles leasing operations.
Instantiating a ShareLeaseClient
ShareLeaseClient fileLeaseClient = new ShareLeaseClientBuilder() .fileClient(shareFileClient) .buildClient();
View this
for additional ways to construct the client.
For more information about leasing see the Azure Docs.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAcquires an infinite lease for write and delete operations.acquireLeaseWithResponse
(ShareAcquireLeaseOptions options, Duration timeout, Context context) Acquires a lease for write and delete operations.acquireLeaseWithResponse
(Duration timeout, Context context) Acquires an infinite lease for write and delete operations.void
Breaks the previously acquired lease, if it exists.breakLeaseWithResponse
(ShareBreakLeaseOptions options, Duration timeout, Context context) Breaks the previously acquired lease, if it exists.breakLeaseWithResponse
(Duration timeout, Context context) Breaks the previously acquired lease, if it exists.changeLease
(String proposedId) Changes the lease ID.changeLeaseWithResponse
(String proposedId, Duration timeout, Context context) Changes the lease ID.Get associated account name.Deprecated.Get the lease ID for this lease.Gets theURL
of the lease client.void
Releases the previously acquired lease.releaseLeaseWithResponse
(Duration timeout, Context context) Releases the previously acquired lease.Renews the previously acquired lease on a share.renewLeaseWithResponse
(Duration timeout, Context context) Renews the previously acquired lease on a share.
-
Method Details
-
getFileUrl
Deprecated.Please usegetResourceUrl()
- Returns:
- URL of the lease client.
-
getResourceUrl
Gets theURL
of the lease client.The lease will either be a share or share file URL depending on which the lease client is associated.
- Returns:
- URL of the lease client.
-
getLeaseId
Get the lease ID for this lease.- Returns:
- the lease ID.
-
acquireLease
Acquires an infinite lease for write and delete operations.Code Samples
System.out.printf("Lease ID is %s%n", client.acquireLease());
- Returns:
- The lease ID.
-
acquireLeaseWithResponse
Acquires an infinite lease for write and delete operations.Code Samples
System.out.printf("Lease ID is %s%n", client .acquireLeaseWithResponse(timeout, new Context(key, value)) .getValue());
- Parameters:
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The lease ID.
-
releaseLease
public void releaseLease()Releases the previously acquired lease.Code Samples
client.releaseLease(); System.out.println("Release lease completed");
-
releaseLeaseWithResponse
Releases the previously acquired lease.Code Samples
System.out.printf("Release lease completed with status %d%n", client.releaseLeaseWithResponse(timeout, new Context(key, value)) .getStatusCode());
- Parameters:
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A response containing status code and HTTP headers.
-
breakLease
public void breakLease()Breaks the previously acquired lease, if it exists. Leases will break immediately.Code Samples
client.breakLease(); System.out.println("The lease has been successfully broken");
-
breakLeaseWithResponse
Breaks the previously acquired lease, if it exists. Leases will break immediately.Code Samples
client.breakLeaseWithResponse(timeout, new Context(key, value)); System.out.println("The lease has been successfully broken");
- Parameters:
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A response containing status code and HTTP headers.
-
changeLease
Changes the lease ID.Code Samples
System.out.printf("Changed lease ID is %s%n", client.changeLease("proposedId"));
- Parameters:
proposedId
- A new lease ID in a valid GUID format.- Returns:
- The new lease ID.
-
changeLeaseWithResponse
public Response<String> changeLeaseWithResponse(String proposedId, Duration timeout, Context context) Changes the lease ID.Code Samples
System.out.printf("Changed lease ID is %s%n", client.changeLeaseWithResponse("proposedId", timeout, new Context(key, value)) .getValue());
- Parameters:
proposedId
- A new lease ID in a valid GUID format.timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The new lease ID.
-
renewLease
Renews the previously acquired lease on a share.Code Samples
System.out.printf("Renewed lease ID is %s%n", client.renewLease());
- Returns:
- A response containing the renewed lease ID.
-
renewLeaseWithResponse
Renews the previously acquired lease on a share.Code Samples
System.out.printf("Renewed lease ID is %s%n", client.releaseLeaseWithResponse(timeout, new Context(key, value)) .getValue());
- Parameters:
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A response containing the renewed lease ID.
-
getAccountName
Get associated account name.- Returns:
- account name associated with this storage resource.
-
getResourceUrl()