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.com.azure.core.http.rest.Response<String>
acquireLeaseWithResponse
(ShareAcquireLeaseOptions options, Duration timeout, com.azure.core.util.Context context) Acquires a lease for write and delete operations.com.azure.core.http.rest.Response<String>
acquireLeaseWithResponse
(Duration timeout, com.azure.core.util.Context context) Acquires an infinite lease for write and delete operations.void
Breaks the previously acquired lease, if it exists.com.azure.core.http.rest.Response<Void>
breakLeaseWithResponse
(ShareBreakLeaseOptions options, Duration timeout, com.azure.core.util.Context context) Breaks the previously acquired lease, if it exists.com.azure.core.http.rest.Response<Void>
breakLeaseWithResponse
(Duration timeout, com.azure.core.util.Context context) Breaks the previously acquired lease, if it exists.changeLease
(String proposedId) Changes the lease ID.com.azure.core.http.rest.Response<String>
changeLeaseWithResponse
(String proposedId, Duration timeout, com.azure.core.util.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.com.azure.core.http.rest.Response<Void>
releaseLeaseWithResponse
(Duration timeout, com.azure.core.util.Context context) Releases the previously acquired lease.Renews the previously acquired lease on a share.com.azure.core.http.rest.Response<String>
renewLeaseWithResponse
(Duration timeout, com.azure.core.util.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
public com.azure.core.http.rest.Response<String> acquireLeaseWithResponse(Duration timeout, com.azure.core.util.Context context) 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
public com.azure.core.http.rest.Response<Void> releaseLeaseWithResponse(Duration timeout, com.azure.core.util.Context context) 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
public com.azure.core.http.rest.Response<Void> breakLeaseWithResponse(Duration timeout, com.azure.core.util.Context context) 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 com.azure.core.http.rest.Response<String> changeLeaseWithResponse(String proposedId, Duration timeout, com.azure.core.util.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
public com.azure.core.http.rest.Response<String> renewLeaseWithResponse(Duration timeout, com.azure.core.util.Context context) 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()