public final class ShareLeaseClient extends Object
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.
ShareLeaseClientBuilder| Modifier and Type | Method and Description |
|---|---|
String |
acquireLease()
Acquires an infinite 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.
|
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.
|
void |
breakLease()
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.
|
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.
|
String |
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.
|
String |
getAccountName()
Get associated account name.
|
String |
getFileUrl()
Deprecated.
Please use
ShareLeaseClient.getResourceUrl() |
String |
getLeaseId()
Get the lease ID for this lease.
|
String |
getResourceUrl()
Gets the
URL of the lease client. |
void |
releaseLease()
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.
|
String |
renewLease()
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.
|
@Deprecated public String getFileUrl()
ShareLeaseClient.getResourceUrl()public String getResourceUrl()
URL of the lease client.
The lease will either be a share or share file URL depending on which the lease client is associated.
public String getLeaseId()
public String acquireLease()
Code Samples
System.out.printf("Lease ID is %s%n", client.acquireLease());
public com.azure.core.http.rest.Response<String> acquireLeaseWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
System.out.printf("Lease ID is %s%n", client
.acquireLeaseWithResponse(timeout, new Context(key, value))
.getValue());
timeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public com.azure.core.http.rest.Response<String> acquireLeaseWithResponse(ShareAcquireLeaseOptions options, Duration timeout, com.azure.core.util.Context context)
Code Samples
System.out.printf("Lease ID is %s%n", client
.acquireLeaseWithResponse(new ShareAcquireLeaseOptions().setDuration(10), timeout, new Context(key, value))
.getValue());
options - ShareAcquireLeaseOptionstimeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public void releaseLease()
Code Samples
client.releaseLease();
System.out.println("Release lease completed");
public com.azure.core.http.rest.Response<Void> releaseLeaseWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
System.out.printf("Release lease completed with status %d%n",
client.releaseLeaseWithResponse(timeout, new Context(key, value))
.getStatusCode());
timeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public void breakLease()
Code Samples
client.breakLease();
System.out.println("The lease has been successfully broken");
public com.azure.core.http.rest.Response<Void> breakLeaseWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
client.breakLeaseWithResponse(timeout, new Context(key, value));
System.out.println("The lease has been successfully broken");
timeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public com.azure.core.http.rest.Response<Void> breakLeaseWithResponse(ShareBreakLeaseOptions options, Duration timeout, com.azure.core.util.Context context)
Code Samples
client.breakLeaseWithResponse(new ShareBreakLeaseOptions().setBreakPeriod(Duration.ofSeconds(25)),
timeout, new Context(key, value));
System.out.println("The lease has been successfully broken");
options - ShareBreakLeaseOptionstimeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public String changeLease(String proposedId)
Code Samples
System.out.printf("Changed lease ID is %s%n", client.changeLease("proposedId"));
proposedId - A new lease ID in a valid GUID format.public com.azure.core.http.rest.Response<String> changeLeaseWithResponse(String proposedId, Duration timeout, com.azure.core.util.Context context)
Code Samples
System.out.printf("Changed lease ID is %s%n",
client.changeLeaseWithResponse("proposedId", timeout, new Context(key, value))
.getValue());
proposedId - A new lease ID in a valid GUID format.timeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public String renewLease()
Code Samples
System.out.printf("Renewed lease ID is %s%n", client.renewLease());
public com.azure.core.http.rest.Response<String> renewLeaseWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
System.out.printf("Renewed lease ID is %s%n",
client.releaseLeaseWithResponse(timeout, new Context(key, value))
.getValue());
timeout - An optional timeout value beyond which a RuntimeException will be raised.context - Additional context that is passed through the Http pipeline during the service call.public String getAccountName()
Copyright © 2021 Microsoft Corporation. All rights reserved.