Class 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:
    ShareLeaseClientBuilder
    • Method Detail

      • 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<com.azure.core.http.rest.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<com.azure.core.http.rest.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<com.azure.core.http.rest.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<com.azure.core.http.rest.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<com.azure.core.http.rest.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<com.azure.core.http.rest.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<com.azure.core.http.rest.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.