ShareAsyncClient Class

  • java.lang.Object
    • com.azure.storage.file.share.ShareAsyncClient

public class ShareAsyncClient

This class provides a azureFileStorageClient that contains all the operations for interacting with a share in Azure Storage Share. Operations allowed by the azureFileStorageClient are creating and deleting the share, creating snapshots for the share, creating and deleting directories in the share and retrieving and updating properties metadata and access policies of the share.

Instantiating an Asynchronous Share Client

ShareAsyncClient client = new ShareClientBuilder()
     .connectionString("${connectionString}")
     .endpoint("${endpoint}")
     .buildAsyncClient();

View ShareClientBuilder for additional ways to construct the azureFileStorageClient.

Method Summary

Modifier and Type Method and Description
Mono<ShareInfo> create()

Creates the share in the storage account.

Mono<ShareDirectoryAsyncClient> createDirectory(String directoryName)

Creates the directory in the share with the given name.

Mono<ShareDirectoryAsyncClient> createDirectoryIfNotExists(String directoryName)

Creates the directory in the share with the given name if it does not exist.

Mono<Response<ShareDirectoryAsyncClient>> createDirectoryIfNotExistsWithResponse(String directoryName, ShareDirectoryCreateOptions options)

Creates the directory in the share with the given name and associates the passed metadata to it if it does not exist.

Mono<Response<ShareDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)

Creates the directory in the share with the given name and associates the passed metadata to it.

Mono<ShareFileAsyncClient> createFile(String fileName, long maxSize)

Creates the file in the share with the given name and file max size.

Mono<Response<ShareFileAsyncClient>> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)

Creates the file in the share with the given name, file max size and associates the passed properties to it.

Mono<Response<ShareFileAsyncClient>> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, ShareRequestConditions requestConditions)

Creates the file in the share with the given name, file max size and associates the passed properties to it.

Mono<ShareInfo> createIfNotExists()

Creates the share in the storage account if it does not exist.

Mono<Response<ShareInfo>> createIfNotExistsWithResponse(ShareCreateOptions options)

Creates the share in the storage account with the specified options if it does not exist.

Mono<String> createPermission(String filePermission)

Creates a permission at the share level.

Mono<Response<String>> createPermissionWithResponse(String filePermission)

Creates a permission at the share level.

Mono<ShareSnapshotInfo> createSnapshot()

Creates a snapshot of the share with the same metadata associated to the share at the time of creation.

Mono<Response<ShareSnapshotInfo>> createSnapshotWithResponse(Map<String,String> metadata)

Creates a snapshot of the share with the metadata that was passed associated to the snapshot.

Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options)

Creates the share in the storage account with the specified options.

Mono<Response<ShareInfo>> createWithResponse(Map<String,String> metadata, Integer quotaInGB)

Creates the share in the storage account with the specified metadata and quota.

Mono<Void> delete()

Deletes the share in the storage account

Mono<Void> deleteDirectory(String directoryName)

Deletes the specified directory in the share.

Mono<Boolean> deleteDirectoryIfExists(String directoryName)

Deletes the specified directory in the share if exists.

Mono<Response<Boolean>> deleteDirectoryIfExistsWithResponse(String directoryName)

Deletes the specified directory in the share if it exists.

Mono<Response<Void>> deleteDirectoryWithResponse(String directoryName)

Deletes the specified directory in the share.

Mono<Void> deleteFile(String fileName)

Deletes the specified file in the share.

Mono<Boolean> deleteFileIfExists(String fileName)

Deletes the specified file in the share if it exists.

Mono<Response<Boolean>> deleteFileIfExistsWithResponse(String fileName, ShareRequestConditions requestConditions)

Deletes the specified file in the share if it exists.

Mono<Response<Void>> deleteFileWithResponse(String fileName)

Deletes the specified file in the share.

Mono<Response<Void>> deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions)

Deletes the specified file in the share.

Mono<Boolean> deleteIfExists()

Deletes the share in the storage account if it exists.

Mono<Response<Boolean>> deleteIfExistsWithResponse(ShareDeleteOptions options)

Deletes the share in the storage account if it exists

Mono<Response<Void>> deleteWithResponse()

Deletes the share in the storage account

Mono<Response<Void>> deleteWithResponse(ShareDeleteOptions options)

Deletes the share in the storage account

Mono<Boolean> exists()

Determines if the share this client represents exists in the cloud.

Mono<Response<Boolean>> existsWithResponse()

Determines if the share this client represents exists in the cloud.

String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)

Generates a service sas for the queue using the specified ShareServiceSasSignatureValues

String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Context context)

Generates a service sas for the queue using the specified ShareServiceSasSignatureValues

PagedFlux<ShareSignedIdentifier> getAccessPolicy()

Retrieves stored access policies specified for the share.

PagedFlux<ShareSignedIdentifier> getAccessPolicy(ShareGetAccessPolicyOptions options)

Retrieves stored access policies specified for the share.

String getAccountName()

Get associated account name.

String getAccountUrl()

Get the url of the storage account.

ShareDirectoryAsyncClient getDirectoryClient(String directoryName)

Constructs a ShareDirectoryAsyncClient that interacts with the specified directory.

ShareFileAsyncClient getFileClient(String filePath)

Constructs a ShareFileAsyncClient that interacts with the specified file.

HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Mono<String> getPermission(String filePermissionKey)

Gets a permission for a given key.

Mono<Response<String>> getPermissionWithResponse(String filePermissionKey)

Gets a permission for a given key.

Mono<ShareProperties> getProperties()

Retrieves the properties of the share, these include the metadata associated to it and the quota that the share is restricted to.

Mono<Response<ShareProperties>> getPropertiesWithResponse()

Retrieves the properties of the share, these include the metadata associated with it and the quota that the share is restricted to.

Mono<Response<ShareProperties>> getPropertiesWithResponse(ShareGetPropertiesOptions options)

Retrieves the properties of the share, these include the metadata associated with it and the quota that the share is restricted to.

ShareDirectoryAsyncClient getRootDirectoryClient()

Constructs a ShareDirectoryAsyncClient that interacts with the root directory in the share.

ShareServiceVersion getServiceVersion()

Gets the service version the client is using.

String getShareName()

Get share name from share client.

String getShareUrl()

Get the url of the storage share client.

ShareAsyncClient getSnapshotClient(String snapshot)

Creates a new ShareAsyncClient linked to the snapshot of this share resource.

String getSnapshotId()

Get snapshot id which attached to ShareAsyncClient.

Mono<ShareStatistics> getStatistics()

Retrieves storage statistics about the share.

Mono<Response<ShareStatistics>> getStatisticsWithResponse()

Retrieves storage statistics about the share.

Mono<Response<ShareStatistics>> getStatisticsWithResponse(ShareGetStatisticsOptions options)

Retrieves storage statistics about the share.

Mono<ShareInfo> setAccessPolicy(List<ShareSignedIdentifier> permissions)

Sets stored access policies for the share.

Mono<Response<ShareInfo>> setAccessPolicyWithResponse(ShareSetAccessPolicyOptions options)

Sets stored access policies for the share.

Mono<Response<ShareInfo>> setAccessPolicyWithResponse(List<ShareSignedIdentifier> permissions)

Sets stored access policies for the share.

Mono<ShareInfo> setMetadata(Map<String,String> metadata)

Sets the user-defined metadata to associate to the share.

Mono<Response<ShareInfo>> setMetadataWithResponse(ShareSetMetadataOptions options)

Sets the user-defined metadata to associate to the share.

Mono<Response<ShareInfo>> setMetadataWithResponse(Map<String,String> metadata)

Sets the user-defined metadata to associate to the share.

Mono<ShareInfo> setProperties(ShareSetPropertiesOptions options)

Sets the share's properties.

Mono<Response<ShareInfo>> setPropertiesWithResponse(ShareSetPropertiesOptions options)

Sets the share's properties.

Mono<ShareInfo> setQuota(int quotaInGB)

Deprecated

Sets the maximum size in GB that the share is allowed to grow.

Mono<Response<ShareInfo>> setQuotaWithResponse(int quotaInGB)

Deprecated

Sets the maximum size in GB that the share is allowed to grow.

Methods inherited from java.lang.Object

Method Details

create

public Mono create()

Creates the share in the storage account.

Code Samples

Create the share

shareAsyncClient.create().subscribe(
     response -> {
     },
     error -> System.err.print(error.toString()),
     () -> System.out.println("Complete creating the share!")
 );

For more information, see the Azure Docs.

Returns:

The information about the ShareInfo

createDirectory

public Mono createDirectory(String directoryName)

Creates the directory in the share with the given name.

Code Samples

Create the directory "mydirectory"

shareAsyncClient.createDirectory("mydirectory").subscribe(
     response -> {
     },
     error -> System.err.print(error.toString()),
     () -> System.out.println("Complete creating the directory!")
 );

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

The ShareDirectoryAsyncClient to interact with the created directory.

createDirectoryIfNotExists

public Mono createDirectoryIfNotExists(String directoryName)

Creates the directory in the share with the given name if it does not exist.

Code Samples

Create the directory "mydirectory"

shareAsyncClient.createDirectoryIfNotExists("mydirectory")
     .switchIfEmpty(Mono.<ShareDirectoryAsyncClient>empty()
         .doOnSuccess(x -> System.out.println("Already exists.")))
     .subscribe(response -> System.out.println("Create completed."));

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

A Mono containing a ShareDirectoryAsyncClient used to interact with the directory created.

createDirectoryIfNotExistsWithResponse

public Mono<>> createDirectoryIfNotExistsWithResponse(String directoryName, ShareDirectoryCreateOptions options)

Creates the directory in the share with the given name and associates the passed metadata to it if it does not exist.

Code Samples

Create the directory "documents" with metadata "directory:metadata"

FileSmbProperties smbProperties = new FileSmbProperties();
 String filePermission = "filePermission";
 Map<String, String> metadata = Collections.singletonMap("directory", "metadata");
 ShareDirectoryCreateOptions options = new ShareDirectoryCreateOptions().setSmbProperties(smbProperties)
     .setFilePermission(filePermission).setMetadata(metadata);

 shareAsyncClient.createDirectoryIfNotExistsWithResponse("documents", options).subscribe(response -> {
     if (response.getStatusCode() == 409) {
         System.out.println("Already exists.");
     } else {
         System.out.println("successfully created.");
     }
 });

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

A Mono containing a Response<T> whose value contains a ShareDirectoryAsyncClient used to interact with the directory created. If Response<T>'s status code is 201, a new directory was successfully created. If status code is 409, a directory with the same name already existed at this location.

createDirectoryWithResponse

public Mono<>> createDirectoryWithResponse(String directoryName, FileSmbProperties smbProperties, String filePermission, Map metadata)

Creates the directory in the share with the given name and associates the passed metadata to it.

Code Samples

Create the directory "documents" with metadata "directory:metadata"

FileSmbProperties smbProperties = new FileSmbProperties();
 String filePermission = "filePermission";
 shareAsyncClient.createDirectoryWithResponse("documents", smbProperties, filePermission,
     Collections.singletonMap("directory", "metadata"))
     .subscribe(response -> System.out.printf("Creating the directory completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory
smbProperties - The SMB properties of the directory.
filePermission - The file permission of the directory.
metadata - Optional metadata to associate with the directory

Returns:

A response containing a ShareDirectoryAsyncClient to interact with the created directory and the status of its creation.

createFile

public Mono createFile(String fileName, long maxSize)

Creates the file in the share with the given name and file max size.

Code Samples

Create the file "myfile" with size of 1024 bytes.

shareAsyncClient.createFile("myfile", 1024).subscribe(
     response -> {
     },
     error -> System.err.print(error.toString()),
     () -> System.out.println("Complete creating the directory!")
 );

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.
maxSize - The maximum size in bytes for the file.

Returns:

The ShareFileAsyncClient to interact with the created file.

createFileWithResponse

public Mono<>> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map metadata)

Creates the file in the share with the given name, file max size and associates the passed properties to it.

Code Samples

Create the file "myfile" with length of 1024 bytes, some headers, file smb properties and metadata

ShareFileHttpHeaders httpHeaders = new ShareFileHttpHeaders()
     .setContentType("text/html")
     .setContentEncoding("gzip")
     .setContentLanguage("en")
     .setCacheControl("no-transform")
     .setContentDisposition("attachment");
 FileSmbProperties smbProperties = new FileSmbProperties()
     .setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
     .setFileCreationTime(OffsetDateTime.now())
     .setFileLastWriteTime(OffsetDateTime.now())
     .setFilePermissionKey("filePermissionKey");
 String filePermission = "filePermission";
 // NOTE: filePermission and filePermissionKey should never be both set
 shareAsyncClient.createFileWithResponse("myfile", 1024, httpHeaders, smbProperties,
     filePermission, Collections.singletonMap("directory", "metadata"))
     .subscribe(response -> System.out.printf("Creating the file completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.
maxSize - The maximum size in bytes for the file.
httpHeaders - The user settable file http headers.
smbProperties - The user settable file smb properties.
filePermission - The file permission of the file.
metadata - Optional name-value pairs associated with the file as metadata.

Returns:

A response containing a ShareFileAsyncClient to interact with the created file and the status of its creation.

createFileWithResponse

public Mono<>> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map metadata, ShareRequestConditions requestConditions)

Creates the file in the share with the given name, file max size and associates the passed properties to it.

Code Samples

Create the file "myfile" with length of 1024 bytes, some headers, file smb properties and metadata

ShareFileHttpHeaders httpHeaders = new ShareFileHttpHeaders()
     .setContentType("text/html")
     .setContentEncoding("gzip")
     .setContentLanguage("en")
     .setCacheControl("no-transform")
     .setContentDisposition("attachment");
 FileSmbProperties smbProperties = new FileSmbProperties()
     .setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
     .setFileCreationTime(OffsetDateTime.now())
     .setFileLastWriteTime(OffsetDateTime.now())
     .setFilePermissionKey("filePermissionKey");
 String filePermission = "filePermission";
 // NOTE: filePermission and filePermissionKey should never be both set

 ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);

 shareAsyncClient.createFileWithResponse("myfile", 1024, httpHeaders, smbProperties,
     filePermission, Collections.singletonMap("directory", "metadata"), requestConditions)
     .subscribe(response -> System.out.printf("Creating the file completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.
maxSize - The maximum size in bytes for the file.
httpHeaders - The user settable file http headers.
smbProperties - The user settable file smb properties.
filePermission - The file permission of the file.
metadata - Optional name-value pairs associated with the file as metadata.
requestConditions - ShareRequestConditions

Returns:

A response containing a ShareFileAsyncClient to interact with the created file and the status of its creation.

createIfNotExists

public Mono createIfNotExists()

Creates the share in the storage account if it does not exist.

Code Samples

Create the share

shareAsyncClient.createIfNotExists().subscribe(response ->
     System.out.printf("Created at %s%n", response.getLastModified()));

For more information, see the Azure Docs.

Returns:

A reactive response Mono signaling completion. ShareInfo contains information about the created share.

createIfNotExistsWithResponse

public Mono<>> createIfNotExistsWithResponse(ShareCreateOptions options)

Creates the share in the storage account with the specified options if it does not exist.

Code Samples

Create the share with optional parameters

shareAsyncClient.createIfNotExistsWithResponse(new ShareCreateOptions()
     .setMetadata(Collections.singletonMap("share", "metadata")).setQuotaInGb(1)
     .setAccessTier(ShareAccessTier.HOT)).subscribe(response -> {
         if (response.getStatusCode() == 409) {
             System.out.println("Already exists.");
         } else {
             System.out.println("successfully created.");
         }
     });

For more information, see the Azure Docs.

Parameters:

options - ShareCreateOptions

Returns:

A Mono containing Response<T> signaling completion, whose value contains a ShareInfo containing information about the share. If Response<T>'s status code is 201, a new share was successfully created. If status code is 409, a share already existed at this location.

createPermission

public Mono createPermission(String filePermission)

Creates a permission at the share level. If a permission already exists, it returns the key of it, else creates a new permission and returns the key.

Code Samples

shareAsyncClient.createPermission("filePermission").subscribe(
     response -> System.out.printf("The file permission key is %s", response));

Parameters:

filePermission - The file permission to get/create.

Returns:

The file permission key associated with the file permission.

createPermissionWithResponse

public Mono<>> createPermissionWithResponse(String filePermission)

Creates a permission at the share level. If a permission already exists, it returns the key of it, else creates a new permission and returns the key.

Code Samples

shareAsyncClient.createPermissionWithResponse("filePermission").subscribe(
     response -> System.out.printf("The file permission key is %s", response.getValue()));

Parameters:

filePermission - The file permission to get/create.

Returns:

A response that contains the file permission key associated with the file permission.

createSnapshot

public Mono createSnapshot()

Creates a snapshot of the share with the same metadata associated to the share at the time of creation.

Code Samples

Create a snapshot

shareAsyncClient.createSnapshot().subscribe(
     response -> System.out.println("Successfully creating the share snapshot with snapshot id: "
         + response.getSnapshot()),
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete creating the share snapshot.")
 );

For more information, see the Azure Docs.

Returns:

The information about the ShareSnapshotInfo.

createSnapshotWithResponse

public Mono<>> createSnapshotWithResponse(Map metadata)

Creates a snapshot of the share with the metadata that was passed associated to the snapshot.

Code Samples

Create a snapshot with metadata "snapshot:metadata"

shareAsyncClient.createSnapshotWithResponse(Collections.singletonMap("snapshot", "metadata")).subscribe(
     response -> System.out.println("Successfully creating the share snapshot with snapshot id: "
         + response.getValue().getSnapshot()),
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete creating the share snapshot.")
 );

For more information, see the Azure Docs.

Parameters:

metadata - Optional metadata to associate with the snapshot. If null the metadata of the share will be copied to the snapshot.

Returns:

A response containing information about the ShareSnapshotInfo.

createWithResponse

public Mono<>> createWithResponse(ShareCreateOptions options)

Creates the share in the storage account with the specified options.

Code Samples

Create the share with optional parameters

shareAsyncClient.createWithResponse(new ShareCreateOptions()
     .setMetadata(Collections.singletonMap("share", "metadata")).setQuotaInGb(1)
     .setAccessTier(ShareAccessTier.HOT)).subscribe(
         response -> System.out.printf("Creating the share completed with status code %d",
             response.getStatusCode()),
         error -> System.err.print(error.toString()),
         () -> System.out.println("Complete creating the share!")
 );

For more information, see the Azure Docs.

Parameters:

options - ShareCreateOptions

Returns:

A response containing information about the ShareInfo and the status its creation.

createWithResponse

public Mono<>> createWithResponse(Map metadata, Integer quotaInGB)

Creates the share in the storage account with the specified metadata and quota.

Code Samples

Create the share with metadata "share:metadata"

shareAsyncClient.createWithResponse(Collections.singletonMap("share", "metadata"), null).subscribe(
     response -> System.out.printf("Creating the share completed with status code %d", response.getStatusCode()),
     error -> System.err.print(error.toString()),
     () -> System.out.println("Complete creating the share!")
 );

Create the share with a quota of 10 GB

shareAsyncClient.createWithResponse(null, 10).subscribe(
     response -> System.out.printf("Creating the share completed with status code %d", response.getStatusCode()),
     error -> System.err.print(error.toString()),
     () -> System.out.println("Complete creating the share!")
 );

For more information, see the Azure Docs.

Parameters:

metadata - Optional metadata to associate with the share
quotaInGB - Optional maximum size the share is allowed to grow to in GB. This must be greater than 0 and less than or equal to 5120. The default value is 5120.

Returns:

A response containing information about the ShareInfo and the status its creation.

delete

public Mono delete()

Deletes the share in the storage account

Code Samples

Delete the share

shareAsyncClient.delete().subscribe(
     response -> System.out.println("Deleting the shareAsyncClient completed."),
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the share.")
 );

For more information, see the Azure Docs.

Returns:

An empty response

deleteDirectory

public Mono deleteDirectory(String directoryName)

Deletes the specified directory in the share.

Code Samples

Delete the directory "mydirectory"

shareAsyncClient.deleteDirectory("mydirectory").subscribe(
     response -> {
     },
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the directory.")
 );

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

An empty response

deleteDirectoryIfExists

public Mono deleteDirectoryIfExists(String directoryName)

Deletes the specified directory in the share if exists.

Code Samples

Delete the directory "mydirectory"

shareAsyncClient.deleteDirectoryIfExists("mydirectory").subscribe(deleted -> {
     if (deleted) {
         System.out.println("Successfully deleted.");
     } else {
         System.out.println("Does not exist.");
     }
 });

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

a reactive response signaling completion. true indicates that the directory was successfully deleted, false indicates that the directory did not exist.

deleteDirectoryIfExistsWithResponse

public Mono<>> deleteDirectoryIfExistsWithResponse(String directoryName)

Deletes the specified directory in the share if it exists.

Code Samples

Delete the directory "mydirectory"

shareAsyncClient.deleteDirectoryIfExistsWithResponse("mydirectory").subscribe(response -> {
     if (response.getStatusCode() == 404) {
         System.out.println("Does not exist.");
     } else {
         System.out.println("successfully deleted.");
     }
 });

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

A reactive response signaling completion. If Response<T>'s status code is 202, the directory was successfully deleted. If status code is 404, the directory does not exist.

deleteDirectoryWithResponse

public Mono<>> deleteDirectoryWithResponse(String directoryName)

Deletes the specified directory in the share.

Code Samples

Delete the directory "mydirectory"

shareAsyncClient.deleteDirectory("mydirectory").subscribe(
     response -> {
     },
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the directory.")
 );

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

A response that only contains headers and response status code

deleteFile

public Mono deleteFile(String fileName)

Deletes the specified file in the share.

Code Samples

Delete the file "myfile"

shareAsyncClient.deleteFile("myfile").subscribe(
     response -> {
     },
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the file.")
 );

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.

Returns:

A empty response

deleteFileIfExists

public Mono deleteFileIfExists(String fileName)

Deletes the specified file in the share if it exists.

Code Samples

Delete the file "myfile"

shareAsyncClient.deleteFileIfExists("myfile").subscribe(deleted -> {
     if (deleted) {
         System.out.println("Successfully deleted.");
     } else {
         System.out.println("Does not exist.");
     }
 });

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.

Returns:

a reactive response signaling completion. true indicates that the file was successfully deleted, false indicates that the file did not exist.

deleteFileIfExistsWithResponse

public Mono<>> deleteFileIfExistsWithResponse(String fileName, ShareRequestConditions requestConditions)

Deletes the specified file in the share if it exists.

Code Samples

Delete the file "myfile"

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);

 shareAsyncClient.deleteFileIfExistsWithResponse("myfile", requestConditions).subscribe(response -> {
     if (response.getStatusCode() == 404) {
         System.out.println("Does not exist.");
     } else {
         System.out.println("successfully deleted.");
     }
 });

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.
requestConditions - ShareRequestConditions

Returns:

A reactive response signaling completion. If Response<T>'s status code is 202, the file was successfully deleted. If status code is 404, the file does not exist.

deleteFileWithResponse

public Mono<>> deleteFileWithResponse(String fileName)

Deletes the specified file in the share.

Code Samples

Delete the file "myfile"

shareAsyncClient.deleteFile("myfile").subscribe(
     response -> {
     },
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the file.")
 );

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.

Returns:

A response that only contains headers and response status code

deleteFileWithResponse

public Mono<>> deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions)

Deletes the specified file in the share.

Code Samples

Delete the file "myfile"

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareAsyncClient.deleteFileWithResponse("myfile", requestConditions).subscribe(
     response -> {
     },
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the file.")
 );

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file.
requestConditions - ShareRequestConditions

Returns:

A response that only contains headers and response status code

deleteIfExists

public Mono deleteIfExists()

Deletes the share in the storage account if it exists.

Code Samples

Delete the share

shareAsyncClient.deleteIfExists().subscribe(deleted -> {
     if (deleted) {
         System.out.println("Successfully deleted.");
     } else {
         System.out.println("Does not exist.");
     }
 });

For more information, see the Azure Docs.

Returns:

a reactive response signaling completion. true indicates that the share was successfully deleted, false indicates that the share did not exist.

deleteIfExistsWithResponse

public Mono<>> deleteIfExistsWithResponse(ShareDeleteOptions options)

Deletes the share in the storage account if it exists

Code Samples

Delete the share

shareAsyncClient.deleteIfExistsWithResponse(new ShareDeleteOptions()
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId))).subscribe(response -> {
         if (response.getStatusCode() == 404) {
             System.out.println("Does not exist.");
         } else {
             System.out.println("successfully deleted.");
         }
     });

For more information, see the Azure Docs.

Parameters:

options - ShareDeleteOptions

Returns:

A reactive response signaling completion. If Response<T>'s status code is 202, the share was successfully deleted. If status code is 404, the share does not exist.

deleteWithResponse

public Mono<>> deleteWithResponse()

Deletes the share in the storage account

Code Samples

Delete the share

shareAsyncClient.deleteWithResponse().subscribe(
     response -> System.out.println("Deleting the shareAsyncClient completed with status code: "
         + response.getStatusCode()),
     error -> System.err.println(error.toString()),
     () -> System.out.println("Complete deleting the share.")
 );

For more information, see the Azure Docs.

Returns:

A response that only contains headers and response status code

deleteWithResponse

public Mono<>> deleteWithResponse(ShareDeleteOptions options)

Deletes the share in the storage account

Code Samples

Delete the share

shareAsyncClient.deleteWithResponse(new ShareDeleteOptions()
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId))).subscribe(
         response -> System.out.println("Deleting the shareAsyncClient completed with status code: "
             + response.getStatusCode()), error -> System.err.println(error.toString()),
         () -> System.out.println("Complete deleting the share.")
 );

For more information, see the Azure Docs.

Parameters:

options - ShareDeleteOptions

Returns:

A response that only contains headers and response status code

exists

public Mono exists()

Determines if the share this client represents exists in the cloud.

Code Samples

client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));

Returns:

Flag indicating existence of the share.

existsWithResponse

public Mono<>> existsWithResponse()

Determines if the share this client represents exists in the cloud.

Code Samples

client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));

Returns:

Flag indicating existence of the share.

generateSas

public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)

Generates a service sas for the queue using the specified ShareServiceSasSignatureValues

Note : The client must be authenticated via StorageSharedKeyCredential

See ShareServiceSasSignatureValues for more information on how to construct a service SAS.

Code Samples

OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
 ShareSasPermission permission = new ShareSasPermission().setReadPermission(true);

 ShareServiceSasSignatureValues values = new ShareServiceSasSignatureValues(expiryTime, permission)
     .setStartTime(OffsetDateTime.now());

 shareAsyncClient.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential

Parameters:

shareServiceSasSignatureValues - ShareServiceSasSignatureValues

Returns:

A String representing the SAS query parameters.

generateSas

public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Context context)

Generates a service sas for the queue using the specified ShareServiceSasSignatureValues

Note : The client must be authenticated via StorageSharedKeyCredential

See ShareServiceSasSignatureValues for more information on how to construct a service SAS.

Code Samples

OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
 ShareSasPermission permission = new ShareSasPermission().setReadPermission(true);

 ShareServiceSasSignatureValues values = new ShareServiceSasSignatureValues(expiryTime, permission)
     .setStartTime(OffsetDateTime.now());

 // Client must be authenticated via StorageSharedKeyCredential
 shareAsyncClient.generateSas(values, new Context("key", "value"));

Parameters:

shareServiceSasSignatureValues - ShareServiceSasSignatureValues
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

getAccessPolicy

public PagedFlux getAccessPolicy()

Retrieves stored access policies specified for the share.

Code Samples

List the stored access policies

shareAsyncClient.getAccessPolicy()
     .subscribe(result -> System.out.printf("Access policy %s allows these permissions: %s", result.getId(),
         result.getAccessPolicy().getPermissions())
     );

For more information, see the Azure Docs.

Returns:

The stored access policies specified on the queue.

getAccessPolicy

public PagedFlux getAccessPolicy(ShareGetAccessPolicyOptions options)

Retrieves stored access policies specified for the share.

Code Samples

List the stored access policies

shareAsyncClient.getAccessPolicy(new ShareGetAccessPolicyOptions()
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))
     .subscribe(result -> System.out.printf("Access policy %s allows these permissions: %s", result.getId(),
         result.getAccessPolicy().getPermissions())
     );

For more information, see the Azure Docs.

Parameters:

Returns:

The stored access policies specified on the queue.

getAccountName

public String getAccountName()

Get associated account name.

Returns:

account name associated with this storage resource.

getAccountUrl

public String getAccountUrl()

Get the url of the storage account.

Returns:

the URL of the storage account

getDirectoryClient

public ShareDirectoryAsyncClient getDirectoryClient(String directoryName)

Constructs a ShareDirectoryAsyncClient that interacts with the specified directory.

If the directory doesn't exist in the share create() in the azureFileStorageClient will need to be called before interaction with the directory can happen.

Parameters:

directoryName - Name of the directory

Returns:

a ShareDirectoryAsyncClient that interacts with the directory in the share

getFileClient

public ShareFileAsyncClient getFileClient(String filePath)

Constructs a ShareFileAsyncClient that interacts with the specified file.

If the file doesn't exist in the share create(long maxSize) ) create} in the client will need to be called before interaction with the file can happen.

Parameters:

filePath - Name of the file

Returns:

a ShareFileAsyncClient that interacts with the file in the share

getHttpPipeline

public HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Returns:

The pipeline.

getPermission

public Mono getPermission(String filePermissionKey)

Gets a permission for a given key.

Code Samples

shareAsyncClient.getPermission("filePermissionKey").subscribe(
     response -> System.out.printf("The file permission is %s", response));

Parameters:

filePermissionKey - The file permission key.

Returns:

The file permission associated with the file permission key.

getPermissionWithResponse

public Mono<>> getPermissionWithResponse(String filePermissionKey)

Gets a permission for a given key.

Code Samples

shareAsyncClient.getPermissionWithResponse("filePermissionKey").subscribe(
     response -> System.out.printf("The file permission is %s", response.getValue()));

Parameters:

filePermissionKey - The file permission key.

Returns:

A response that contains th file permission associated with the file permission key.

getProperties

public Mono getProperties()

Retrieves the properties of the share, these include the metadata associated to it and the quota that the share is restricted to.

Code Samples

Retrieve the share properties

shareAsyncClient.getProperties()
     .subscribe(properties -> {
         System.out.printf("Share quota: %d, Metadata: %s", properties.getQuota(), properties.getMetadata());
     });

For more information, see the Azure Docs.

Returns:

getPropertiesWithResponse

public Mono<>> getPropertiesWithResponse()

Retrieves the properties of the share, these include the metadata associated with it and the quota that the share is restricted to.

Code Samples

Retrieve the share properties

shareAsyncClient.getPropertiesWithResponse()
     .subscribe(properties -> {
         System.out.printf("Share quota: %d, Metadata: %s", properties.getValue().getQuota(),
             properties.getValue().getMetadata());
     });

For more information, see the Azure Docs.

Returns:

A response containing the ShareProperties with headers and response status code

getPropertiesWithResponse

public Mono<>> getPropertiesWithResponse(ShareGetPropertiesOptions options)

Retrieves the properties of the share, these include the metadata associated with it and the quota that the share is restricted to.

Code Samples

Retrieve the share properties

shareAsyncClient.getPropertiesWithResponse(new ShareGetPropertiesOptions()
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))
     .subscribe(properties -> {
         System.out.printf("Share quota: %d, Metadata: %s", properties.getValue().getQuota(),
             properties.getValue().getMetadata());
     });

For more information, see the Azure Docs.

Parameters:

Returns:

A response containing the ShareProperties with headers and response status code

getRootDirectoryClient

public ShareDirectoryAsyncClient getRootDirectoryClient()

Constructs a ShareDirectoryAsyncClient that interacts with the root directory in the share.

If the directory doesn't exist in the share create() in the azureFileStorageClient will need to be called before interaction with the directory can happen.

Returns:

a ShareDirectoryAsyncClient that interacts with the root directory in the share

getServiceVersion

public ShareServiceVersion getServiceVersion()

Gets the service version the client is using.

Returns:

the service version the client is using.

getShareName

public String getShareName()

Get share name from share client.

Code Samples

String shareName = shareAsyncClient.getShareName();
 System.out.println("The name of the share is " + shareName);

Returns:

The name of the share.

getShareUrl

public String getShareUrl()

Get the url of the storage share client.

Returns:

the url of the Storage Share.

getSnapshotClient

public ShareAsyncClient getSnapshotClient(String snapshot)

Creates a new ShareAsyncClient linked to the snapshot of this share resource.

Parameters:

snapshot - the identifier for a specific snapshot of this share

Returns:

a ShareAsyncClient used to interact with the specific snapshot.

getSnapshotId

public String getSnapshotId()

Get snapshot id which attached to ShareAsyncClient. Return null if no snapshot id attached.

Code Samples

Get the share snapshot id.

OffsetDateTime currentTime = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC);
 ShareAsyncClient shareAsyncClient = new ShareClientBuilder()
     .endpoint("https://${accountName}.file.core.windows.net")
     .sasToken("${SASToken}")
     .shareName("myshare")
     .snapshot(currentTime.toString())
     .buildAsyncClient();

 System.out.printf("Snapshot ID: %s%n", shareAsyncClient.getSnapshotId());

Returns:

The snapshot id which is a unique DateTime value that identifies the share snapshot to its base share.

getStatistics

public Mono getStatistics()

Retrieves storage statistics about the share.

Code Samples

Retrieve the storage statistics

shareAsyncClient.getStatistics().doOnSuccess(response -> System.out.printf("The share is using %d GB",
     response.getShareUsageInGB()));

For more information, see the Azure Docs.

Returns:

The storage ShareStatistics

getStatisticsWithResponse

public Mono<>> getStatisticsWithResponse()

Retrieves storage statistics about the share.

Code Samples

Retrieve the storage statistics

shareAsyncClient.getStatisticsWithResponse().subscribe(response -> System.out.printf("The share is using %d GB",
     response.getValue().getShareUsageInGB()));

For more information, see the Azure Docs.

Returns:

A response containing the storage ShareStatistics with headers and response status code

getStatisticsWithResponse

public Mono<>> getStatisticsWithResponse(ShareGetStatisticsOptions options)

Retrieves storage statistics about the share.

Code Samples

Retrieve the storage statistics

shareAsyncClient.getStatisticsWithResponse(new ShareGetStatisticsOptions()
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))
     .subscribe(response -> System.out.printf("The share is using %d GB",
     response.getValue().getShareUsageInGB()));

For more information, see the Azure Docs.

Parameters:

Returns:

A response containing the storage ShareStatistics with headers and response status code

setAccessPolicy

public Mono setAccessPolicy(List permissions)

Sets stored access policies for the share.

Code Samples

Set a read only stored access policy

ShareAccessPolicy accessPolicy = new ShareAccessPolicy().setPermissions("r")
     .setStartsOn(OffsetDateTime.now(ZoneOffset.UTC))
     .setExpiresOn(OffsetDateTime.now(ZoneOffset.UTC).plusDays(10));

 ShareSignedIdentifier permission = new ShareSignedIdentifier().setId("mypolicy").setAccessPolicy(accessPolicy);
 shareAsyncClient.setAccessPolicy(Collections.singletonList(permission)).doOnSuccess(
     response -> System.out.println("Setting access policies completed."));

For more information, see the Azure Docs.

Parameters:

permissions - Access policies to set on the queue

Returns:

setAccessPolicyWithResponse

public Mono<>> setAccessPolicyWithResponse(ShareSetAccessPolicyOptions options)

Sets stored access policies for the share.

Code Samples

Set a read only stored access policy

ShareAccessPolicy accessPolicy = new ShareAccessPolicy().setPermissions("r")
     .setStartsOn(OffsetDateTime.now(ZoneOffset.UTC))
     .setExpiresOn(OffsetDateTime.now(ZoneOffset.UTC).plusDays(10));

 ShareSignedIdentifier permission = new ShareSignedIdentifier().setId("mypolicy").setAccessPolicy(accessPolicy);
 shareAsyncClient.setAccessPolicyWithResponse(new ShareSetAccessPolicyOptions()
     .setPermissions(Collections.singletonList(permission))
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))
     .subscribe(response -> System.out.printf("Setting access policies completed completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

Returns:

A response containing the ShareInfo with headers and response status code

setAccessPolicyWithResponse

public Mono<>> setAccessPolicyWithResponse(List permissions)

Sets stored access policies for the share.

Code Samples

Set a read only stored access policy

ShareAccessPolicy accessPolicy = new ShareAccessPolicy().setPermissions("r")
     .setStartsOn(OffsetDateTime.now(ZoneOffset.UTC))
     .setExpiresOn(OffsetDateTime.now(ZoneOffset.UTC).plusDays(10));

 ShareSignedIdentifier permission = new ShareSignedIdentifier().setId("mypolicy").setAccessPolicy(accessPolicy);
 shareAsyncClient.setAccessPolicyWithResponse(Collections.singletonList(permission))
     .subscribe(response -> System.out.printf("Setting access policies completed completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

permissions - Access policies to set on the queue

Returns:

A response containing the ShareInfo with headers and response status code

setMetadata

public Mono setMetadata(Map metadata)

Sets the user-defined metadata to associate to the share.

If null is passed for the metadata it will clear the metadata associated to the share.

Code Samples

Set the metadata to "share:updatedMetadata"

shareAsyncClient.setMetadata(Collections.singletonMap("share", "updatedMetadata")).doOnSuccess(response ->
     System.out.println("Setting the share metadata completed.")
 );

Clear the metadata of the share

shareAsyncClient.setMetadata(null).doOnSuccess(response ->
     System.out.println("Setting the share metadata completed.")
 );

For more information, see the Azure Docs.

Parameters:

metadata - Metadata to set on the share, if null is passed the metadata for the share is cleared

Returns:

setMetadataWithResponse

public Mono<>> setMetadataWithResponse(ShareSetMetadataOptions options)

Sets the user-defined metadata to associate to the share.

If null is passed for the metadata it will clear the metadata associated to the share.

Code Samples

shareAsyncClient.setMetadataWithResponse(new ShareSetMetadataOptions()
     .setMetadata(Collections.singletonMap("share", "updatedMetadata"))
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))
     .subscribe(response ->
         System.out.printf("Setting the share metadata completed with status code %d", response.getStatusCode())
     );

For more information, see the Azure Docs.

Parameters:

Returns:

A response containing the ShareInfo with headers and response status code

setMetadataWithResponse

public Mono<>> setMetadataWithResponse(Map metadata)

Sets the user-defined metadata to associate to the share.

If null is passed for the metadata it will clear the metadata associated to the share.

Code Samples

Set the metadata to "share:updatedMetadata"

shareAsyncClient.setMetadata(Collections.singletonMap("share", "updatedMetadata")).doOnSuccess(response ->
     System.out.println("Setting the share metadata completed.")
 );

Clear the metadata of the share

shareAsyncClient.setMetadata(null).doOnSuccess(response ->
     System.out.println("Setting the share metadata completed.")
 );

For more information, see the Azure Docs.

Parameters:

metadata - Metadata to set on the share, if null is passed the metadata for the share is cleared

Returns:

A response containing the ShareInfo with headers and response status code

setProperties

public Mono setProperties(ShareSetPropertiesOptions options)

Sets the share's properties.

Code Samples

shareAsyncClient.setProperties(new ShareSetPropertiesOptions().setAccessTier(ShareAccessTier.HOT)
     .setQuotaInGb(2014))
     .doOnSuccess(response -> System.out.println("Setting the share access tier completed."));

For more information, see the Azure Docs.

Parameters:

Returns:

setPropertiesWithResponse

public Mono<>> setPropertiesWithResponse(ShareSetPropertiesOptions options)

Sets the share's properties.

Code Samples

shareAsyncClient.setPropertiesWithResponse(new ShareSetPropertiesOptions().setAccessTier(ShareAccessTier.HOT)
     .setQuotaInGb(1024).setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))
     .subscribe(response ->
         System.out.printf("Setting the share quota completed with status code %d", response.getStatusCode())
     );

For more information, see the Azure Docs.

Parameters:

Returns:

A response containing the ShareInfo with headers and response status code

setQuota

@Deprecated
public Mono setQuota(int quotaInGB)

Deprecated

Sets the maximum size in GB that the share is allowed to grow.

Code Samples

Set the quota to 1024 GB

shareAsyncClient.setQuota(1024).doOnSuccess(response ->
     System.out.println("Setting the share quota completed.")
 );

For more information, see the Azure Docs.

Parameters:

quotaInGB - Size in GB to limit the share's growth. The quota in GB must be between 1 and 5120.

Returns:

setQuotaWithResponse

@Deprecated
public Mono<>> setQuotaWithResponse(int quotaInGB)

Deprecated

Sets the maximum size in GB that the share is allowed to grow.

Code Samples

Set the quota to 1024 GB

shareAsyncClient.setQuotaWithResponse(1024)
     .subscribe(response ->
         System.out.printf("Setting the share quota completed with status code %d", response.getStatusCode())
     );

For more information, see the Azure Docs.

Parameters:

quotaInGB - Size in GB to limit the share's growth. The quota in GB must be between 1 and 5120.

Returns:

A response containing the ShareInfo with headers and response status code

Applies to