Class ShareLeaseAsyncClient

java.lang.Object
com.azure.storage.file.share.specialized.ShareLeaseAsyncClient

public final class ShareLeaseAsyncClient extends Object
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 ShareLeaseAsyncClient

 ShareLeaseAsyncClient fileLeaseAsyncClient = new ShareLeaseClientBuilder()
     .fileAsyncClient(shareFileAsyncClient)
     .buildAsyncClient();
 

View this for additional ways to construct the client.

For more information about leasing see the Azure Docs.

See Also:
  • Method Details

    • getFileUrl

      @Deprecated public String getFileUrl()
      Deprecated.
      Please use getResourceUrl()
      Returns:
      URL of the lease client.
    • getResourceUrl

      public String getResourceUrl()
      Gets the URL 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

      public String getLeaseId()
      Get the lease ID for this lease.
      Returns:
      the lease ID.
    • acquireLease

      public Mono<String> acquireLease()
      Acquires an infinite lease for write and delete operations.

      Code Samples

       client.acquireLease().subscribe(response -> System.out.printf("Lease ID is %s%n", response));
       
      Returns:
      A reactive response containing the lease ID.
    • acquireLeaseWithResponse

      public Mono<Response<String>> acquireLeaseWithResponse()
      Acquires an infinite lease for write and delete operations.

      Code Samples

       client.acquireLeaseWithResponse().subscribe(response ->
           System.out.printf("Lease ID is %s%n", response.getValue()));
       
      Returns:
      A reactive response containing the lease ID.
    • acquireLeaseWithResponse

      public Mono<Response<String>> acquireLeaseWithResponse(ShareAcquireLeaseOptions options)
      Acquires a lease for write and delete operations. Note: Share files only support infinite lease.

      Code Samples

       client.acquireLeaseWithResponse(new ShareAcquireLeaseOptions().setDuration(10)).subscribe(response ->
           System.out.printf("Lease ID is %s%n", response.getValue()));
       
      Parameters:
      options - ShareAcquireLeaseOptions
      Returns:
      A reactive response containing the lease ID.
    • releaseLease

      public Mono<Void> releaseLease()
      Releases the previously acquired lease.

      Code Samples

       client.releaseLease().subscribe(response -> System.out.println("Completed release lease"));
       
      Returns:
      A reactive response signalling completion.
    • releaseLeaseWithResponse

      public Mono<Response<Void>> releaseLeaseWithResponse()
      Releases the previously acquired lease.

      Code Samples

       client.releaseLeaseWithResponse().subscribe(response ->
           System.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
       
      Returns:
      A reactive response signalling completion.
    • breakLease

      public Mono<Void> breakLease()
      Breaks the previously acquired lease, if it exists. Leases will break immediately.

      Code Samples

       client.breakLease().subscribe(response ->
           System.out.println("The lease has been successfully broken"));
       
      Returns:
      A reactive response signalling completion.
    • breakLeaseWithResponse

      public Mono<Response<Void>> breakLeaseWithResponse()
      Breaks the previously acquired lease, if it exists.

      For files, leases will break immediately.

      For shares, leases will break after the specified duration.

      Code Samples

       client.breakLeaseWithResponse().subscribe(response ->
           System.out.println("The lease has been successfully broken"));
       
      Returns:
      A reactive response signalling completion.
    • breakLeaseWithResponse

      public Mono<Response<Void>> breakLeaseWithResponse(ShareBreakLeaseOptions options)
      Breaks the previously acquired lease, if it exists.

      For files, leases will break immediately.

      For shares, leases will break after the specified duration.

      Code Samples

       client.breakLeaseWithResponse(new ShareBreakLeaseOptions().setBreakPeriod(Duration.ofSeconds(25)))
           .subscribe(response -> System.out.println("The lease has been successfully broken"));
       
      Parameters:
      options - ShareBreakLeaseOptions
      Returns:
      A reactive response signalling completion.
    • changeLease

      public Mono<String> changeLease(String proposedId)
      Changes the lease ID.

      Code Samples

       client.changeLease("proposedId").subscribe(response -> System.out.printf("Changed lease ID is %s%n", response));
       
      Parameters:
      proposedId - A new lease ID in a valid GUID format.
      Returns:
      A reactive response containing the new lease ID.
    • changeLeaseWithResponse

      public Mono<Response<String>> changeLeaseWithResponse(String proposedId)
      Changes the lease ID.

      Code Samples

       client.changeLeaseWithResponse("proposedId").subscribe(response ->
           System.out.printf("Changed lease ID is %s%n", response.getValue()));
       
      Parameters:
      proposedId - A new lease ID in a valid GUID format.
      Returns:
      A reactive response containing the new lease ID.
    • renewLease

      public Mono<String> renewLease()
      Renews the previously acquired lease on a share.

      Code Samples

       client.renewLease().subscribe(response -> System.out.printf("Renewed lease ID is %s%n", response));
       
      Returns:
      A reactive response containing the renewed lease ID.
    • renewLeaseWithResponse

      public Mono<Response<String>> renewLeaseWithResponse()
      Renews the previously acquired lease on a share.

      Code Samples

       client.renewLeaseWithResponse().subscribe(response ->
           System.out.printf("Renewed lease ID is %s%n", response.getValue()));
       
      Returns:
      A reactive response containing the renewed lease ID.
    • getAccountName

      public String getAccountName()
      Get associated account name.
      Returns:
      account name associated with this storage resource.