public final class BlobLeaseAsyncClient extends Object
containers
and blobs
. This client acts as a supplement to those clients and only handles leasing
operations.
Instantiating a BlobLeaseAsyncClient
BlobLeaseAsyncClient
blobLeaseAsyncClient = newBlobLeaseClientBuilder
() .blobAsyncClient(blobAsyncClient) .buildAsyncClient();
BlobLeaseAsyncClient
blobLeaseAsyncClient = newBlobLeaseClientBuilder
() .containerAsyncClient(blobContainerAsyncClient) .buildAsyncClient();
View this
for additional ways to construct the client.
For more information about leasing see the container leasing or blob leasing documentation.
BlobLeaseClientBuilder
Modifier and Type | Method and Description |
---|---|
Mono<String> |
acquireLease(int duration)
Acquires a lease for write and delete operations.
|
Mono<Response<String>> |
acquireLeaseWithResponse(int duration,
RequestConditions modifiedAccessConditions)
Acquires a lease for write and delete operations.
|
Mono<Integer> |
breakLease()
Breaks the previously acquired lease, if it exists.
|
Mono<Response<Integer>> |
breakLeaseWithResponse(Integer breakPeriodInSeconds,
RequestConditions modifiedAccessConditions)
Breaks the previously acquired lease, if it exists.
|
Mono<String> |
changeLease(String proposedId)
Changes the lease ID.
|
Mono<Response<String>> |
changeLeaseWithResponse(String proposedId,
RequestConditions modifiedAccessConditions)
Changes the lease ID.
|
String |
getAccountName()
Get associated account name.
|
String |
getLeaseId()
Get the lease ID for this lease.
|
String |
getResourceUrl()
Gets the
URL of the lease client. |
Mono<Void> |
releaseLease()
Releases the previously acquired lease.
|
Mono<Response<Void>> |
releaseLeaseWithResponse(RequestConditions modifiedAccessConditions)
Releases the previously acquired lease.
|
Mono<String> |
renewLease()
Renews the previously acquired lease.
|
Mono<Response<String>> |
renewLeaseWithResponse(RequestConditions modifiedAccessConditions)
Renews the previously acquired lease.
|
public String getResourceUrl()
URL
of the lease client.
The lease will either be a container or blob URL depending on which the lease client is associated.
public String getLeaseId()
public Mono<String> acquireLease(int duration)
Code Samples
client.acquireLease(60).subscribe(response -> System
.out.printf("Lease ID is %s%n", response));
duration
- The duration of the lease between 15 to 60 seconds or -1 for an infinite duration.public Mono<Response<String>> acquireLeaseWithResponse(int duration, RequestConditions modifiedAccessConditions)
Code Samples
RequestConditions
modifiedAccessConditions = newRequestConditions
() .setIfModifiedSince(OffsetDateTime
.now().minusDays(3)); client.acquireLeaseWithResponse(60, modifiedAccessConditions).subscribe(response ->System
.out.printf("Lease ID is %s%n", response.getValue()));
duration
- The duration of the lease between 15 to 60 seconds or -1 for an infinite duration.modifiedAccessConditions
- Standard HTTP Access conditions related to the modification of data. ETag and
LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given
request. The request will fail if the specified condition is not satisfied.public Mono<String> renewLease()
Code Samples
client.renewLease().subscribe(response -> System
.out.printf("Renewed lease ID is %s%n", response));
public Mono<Response<String>> renewLeaseWithResponse(RequestConditions modifiedAccessConditions)
Code Samples
RequestConditions
modifiedAccessConditions = newRequestConditions
() .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3)); client.renewLeaseWithResponse(modifiedAccessConditions).subscribe(response ->System
.out.printf("Renewed lease ID is %s%n", response.getValue()));
modifiedAccessConditions
- Standard HTTP Access conditions related to the modification of data. ETag and
LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given
request. The request will fail if the specified condition is not satisfied.public Mono<Void> releaseLease()
Code Samples
client.releaseLease().subscribe(response -> System
.out.println("Completed release lease"));
public Mono<Response<Void>> releaseLeaseWithResponse(RequestConditions modifiedAccessConditions)
Code Samples
RequestConditions
modifiedAccessConditions = newRequestConditions
() .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3)); client.releaseLeaseWithResponse(modifiedAccessConditions).subscribe(response ->System
.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
modifiedAccessConditions
- Standard HTTP Access conditions related to the modification of data. ETag and
LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given
request. The request will fail if the specified condition is not satisfied.public Mono<Integer> breakLease()
Code Samples
client.breakLease().subscribe(response ->
System
.out.printf("The broken lease has %d seconds remaining on the lease", response));
public Mono<Response<Integer>> breakLeaseWithResponse(Integer breakPeriodInSeconds, RequestConditions modifiedAccessConditions)
If null
is passed for breakPeriodInSeconds
a fixed duration lease will break after the
remaining lease period elapses and an infinite lease will break immediately.
Code Samples
Integer
retainLeaseInSeconds = 5;RequestConditions
modifiedAccessConditions = newRequestConditions
() .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3)); client.breakLeaseWithResponse(retainLeaseInSeconds, modifiedAccessConditions).subscribe(response ->System
.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
breakPeriodInSeconds
- An optional duration, between 0 and 60 seconds, that the lease should continue before
it is broken. If the break period is longer than the time remaining on the lease the remaining time on the lease
is used. A new lease will not be available before the break period has expired, but the lease may be held for
longer than the break period.modifiedAccessConditions
- Standard HTTP Access conditions related to the modification of data. ETag and
LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given
request. The request will fail if the specified condition is not satisfied.public Mono<String> changeLease(String proposedId)
Code Samples
client.changeLease("proposedId").subscribe(response -> System
.out.printf("Changed lease ID is %s%n", response));
proposedId
- A new lease ID in a valid GUID format.public Mono<Response<String>> changeLeaseWithResponse(String proposedId, RequestConditions modifiedAccessConditions)
Code Samples
RequestConditions
modifiedAccessConditions = newRequestConditions
() .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3)); client.changeLeaseWithResponse("proposedId", modifiedAccessConditions).subscribe(response ->System
.out.printf("Changed lease ID is %s%n", response.getValue()));
proposedId
- A new lease ID in a valid GUID format.modifiedAccessConditions
- Standard HTTP Access conditions related to the modification of data. ETag and
LastModifiedTime are used to construct conditions related to when the resource was changed relative to the given
request. The request will fail if the specified condition is not satisfied.public String getAccountName()
Copyright © 2019 Microsoft Corporation. All rights reserved.