Freigeben über


ShareClient Class

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

public class ShareClient

This class provides a client that contains all the operations for interacting with a share in Azure Storage Share. Operations allowed by the client 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 a Synchronous Share Client

ShareClient client = new ShareClientBuilder()
     .connectionString("${connectionString}")
     .endpoint("${endpoint}")
     .buildClient();

View ShareClientBuilder for additional ways to construct the client.

Method Summary

Modifier and Type Method and Description
ShareInfo create()

Creates the share in the storage account.

ShareDirectoryClient createDirectory(String directoryName)

Creates the directory in the share with the given name.

ShareDirectoryClient createDirectoryIfNotExists(String directoryName)

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

Response<ShareDirectoryClient> createDirectoryIfNotExistsWithResponse(String directoryName, ShareDirectoryCreateOptions options, Duration timeout, Context context)

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

Response<ShareDirectoryClient> createDirectoryWithResponse(String directoryName, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, Duration timeout, Context context)

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

ShareFileClient createFile(String fileName, long maxSize)

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

Response<ShareFileClient> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, ShareRequestConditions requestConditions, Duration timeout, Context context)

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

Response<ShareFileClient> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, Duration timeout, Context context)

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

ShareInfo createIfNotExists()

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

Response<ShareInfo> createIfNotExistsWithResponse(ShareCreateOptions options, Duration timeout, Context context)

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

String createPermission(ShareFilePermission filePermission)

Creates a permission at the share level.

String createPermission(String filePermission)

Creates a permission at the share level.

Response<String> createPermissionWithResponse(ShareFilePermission filePermission, Duration timeout, Context context)

Creates a permission at the share level.

Response<String> createPermissionWithResponse(String filePermission, Context context)

Creates a permission t the share level.

ShareSnapshotInfo createSnapshot()

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

Response<ShareSnapshotInfo> createSnapshotWithResponse(Map<String,String> metadata, Duration timeout, Context context)

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

Response<ShareInfo> createWithResponse(ShareCreateOptions options, Duration timeout, Context context)

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

Response<ShareInfo> createWithResponse(Map<String,String> metadata, Integer quotaInGB, Duration timeout, Context context)

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

void delete()

Deletes the share in the storage account

void deleteDirectory(String directoryName)

Deletes the specified directory in the share.

boolean deleteDirectoryIfExists(String directoryName)

Deletes the specified directory in the share if it exists.

Response<Boolean> deleteDirectoryIfExistsWithResponse(String directoryName, Duration timeout, Context context)

Deletes the specified directory in the share if it exists.

Response<Void> deleteDirectoryWithResponse(String directoryName, Duration timeout, Context context)

Deletes the specified directory in the share.

void deleteFile(String fileName)

Deletes the specified file in the share.

boolean deleteFileIfExists(String fileName)

Deletes the specified file in the share if it exists.

Response<Boolean> deleteFileIfExistsWithResponse(String fileName, ShareRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified file in the share if it exists.

Response<Void> deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified file in the share.

Response<Void> deleteFileWithResponse(String fileName, Duration timeout, Context context)

Deletes the specified file in the share.

boolean deleteIfExists()

Deletes the share in the storage account if it exists.

Response<Boolean> deleteIfExistsWithResponse(ShareDeleteOptions options, Duration timeout, Context context)

Deletes the share in the storage account if it exists.

Response<Void> deleteWithResponse(ShareDeleteOptions options, Duration timeout, Context context)

Deletes the share in the storage account

Response<Void> deleteWithResponse(Duration timeout, Context context)

Deletes the share in the storage account

Boolean exists()

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

Response<Boolean> existsWithResponse(Duration timeout, Context context)

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

String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer<String> stringToSignHandler, Context context)

Generates a service sas for the queue using the specified ShareServiceSasSignatureValues

PagedIterable<ShareSignedIdentifier> getAccessPolicy()

Retrieves stored access policies specified for the share.

PagedIterable<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.

ShareDirectoryClient getDirectoryClient(String directoryName)

Constructs a ShareDirectoryClient that interacts with the specified directory.

ShareFileClient getFileClient(String filePath)

Constructs a ShareFileClient that interacts with the specified file.

HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

String getPermission(String filePermissionKey)

Gets a permission for a given key

String getPermission(String filePermissionKey, FilePermissionFormat filePermissionFormat)

Gets a permission for a given key

Response<String> getPermissionWithResponse(String filePermissionKey, Context context)

Gets a permission for a given key.

Response<String> getPermissionWithResponse(String filePermissionKey, FilePermissionFormat filePermissionFormat, Duration timeout, Context context)

Gets a permission for a given key.

ShareProperties getProperties()

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

Response<ShareProperties> getPropertiesWithResponse(ShareGetPropertiesOptions options, Duration timeout, Context context)

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

Response<ShareProperties> getPropertiesWithResponse(Duration timeout, Context context)

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

ShareDirectoryClient getRootDirectoryClient()

Constructs a ShareDirectoryClient 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.

ShareClient getSnapshotClient(String snapshot)

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

String getSnapshotId()

Get snapshot id which attached to ShareClient.

ShareStatistics getStatistics()

Retrieves storage statistics about the share.

Response<ShareStatistics> getStatisticsWithResponse(ShareGetStatisticsOptions options, Duration timeout, Context context)

Retrieves storage statistics about the share.

Response<ShareStatistics> getStatisticsWithResponse(Duration timeout, Context context)

Retrieves storage statistics about the share.

ShareInfo setAccessPolicy(List<ShareSignedIdentifier> permissions)

Sets stored access policies for the share.

Response<ShareInfo> setAccessPolicyWithResponse(ShareSetAccessPolicyOptions options, Duration timeout, Context context)

Sets stored access policies for the share.

Response<ShareInfo> setAccessPolicyWithResponse(List<ShareSignedIdentifier> permissions, Duration timeout, Context context)

Sets stored access policies for the share.

ShareInfo setMetadata(Map<String,String> metadata)

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

Response<ShareInfo> setMetadataWithResponse(ShareSetMetadataOptions options, Duration timeout, Context context)

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

Response<ShareInfo> setMetadataWithResponse(Map<String,String> metadata, Duration timeout, Context context)

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

ShareInfo setProperties(ShareSetPropertiesOptions options)

Sets the share's properties.

Response<ShareInfo> setPropertiesWithResponse(ShareSetPropertiesOptions options, Duration timeout, Context context)

Sets the share's properties.

ShareInfo setQuota(int quotaInGB)

Deprecated

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

Response<ShareInfo> setQuotaWithResponse(int quotaInGB, Duration timeout, Context context)

Deprecated

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

Methods inherited from java.lang.Object

Method Details

create

public ShareInfo create()

Creates the share in the storage account.

Code Samples

Create the share

ShareInfo response = shareClient.create();
 System.out.println("Complete creating the shares with status code: " + response);

For more information, see the Azure Docs.

Returns:

createDirectory

public ShareDirectoryClient createDirectory(String directoryName)

Creates the directory in the share with the given name.

Code Samples

Create the directory "documents"

ShareDirectoryClient response = shareClient.createDirectory("mydirectory");
 System.out.println("Complete creating the directory.");

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

A response containing a ShareDirectoryClient to interact with the created directory.

createDirectoryIfNotExists

public ShareDirectoryClient createDirectoryIfNotExists(String directoryName)

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

Code Samples

Create the directory "documents"

ShareDirectoryClient directoryClient = shareClient.createDirectoryIfNotExists("mydirectory");
 System.out.println("Complete creating the directory.");

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

The ShareDirectoryClient used to interact with the directory created.

createDirectoryIfNotExistsWithResponse

public Response createDirectoryIfNotExistsWithResponse(String directoryName, ShareDirectoryCreateOptions options, Duration timeout, Context context)

Creates the directory if it does not exist 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";
 Map<String, String> metadata = Collections.singletonMap("directory", "metadata");
 ShareDirectoryCreateOptions options = new ShareDirectoryCreateOptions().setSmbProperties(smbProperties).
     setFilePermission(filePermission).setMetadata(metadata);
 Response<ShareDirectoryClient> response = shareClient.createDirectoryIfNotExistsWithResponse("documents",
     options, Duration.ofSeconds(1), new Context(key1, value1));

 if (response.getStatusCode() == 409) {
     System.out.println("Already existed.");
 } else {
     System.out.printf("Create completed with status %d%n", response.getStatusCode());
 }

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A Response<T> whose value contains the ShareDirectoryClient 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 Response createDirectoryWithResponse(String directoryName, FileSmbProperties smbProperties, String filePermission, Map metadata, Duration timeout, Context context)

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";
 Response<ShareDirectoryClient> response = shareClient.createDirectoryWithResponse("documents",
     smbProperties, filePermission, Collections.singletonMap("directory", "metadata"),
     Duration.ofSeconds(1), new Context(key1, value1));
 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
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

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

createFile

public ShareFileClient 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.

ShareFileClient response = shareClient.createFile("myfile", 1024);
 System.out.println("Complete creating the file with snapshot Id:" + response.getShareSnapshotId());

For more information, see the Azure Docs.

Parameters:

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

Returns:

A response containing a ShareFileClient to interact with the created file.

createFileWithResponse

public Response createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map metadata, ShareRequestConditions requestConditions, Duration timeout, Context context)

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);

 Response<ShareFileClient> response = shareClient.createFileWithResponse("myfile", 1024,
     httpHeaders, smbProperties, filePermission, Collections.singletonMap("directory", "metadata"),
     requestConditions, Duration.ofSeconds(1), new Context(key1, value1));
 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 - Additional parameters for the operation.
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
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

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

createFileWithResponse

public Response createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map metadata, Duration timeout, Context context)

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
 Response<ShareFileClient> response = shareClient.createFileWithResponse("myfile", 1024,
     httpHeaders, smbProperties, filePermission, Collections.singletonMap("directory", "metadata"),
     Duration.ofSeconds(1), new Context(key1, value1));
 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 - Additional parameters for the operation.
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.
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

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

createIfNotExists

public ShareInfo createIfNotExists()

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

Code Samples

Create the share

shareClient.createIfNotExists();
 System.out.println("Completed creating the share.");

For more information, see the Azure Docs.

Returns:

ShareInfo that contains information about the created resource.

createIfNotExistsWithResponse

public Response createIfNotExistsWithResponse(ShareCreateOptions options, Duration timeout, Context context)

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

Code Samples

Response<ShareInfo> response = shareClient.createIfNotExistsWithResponse(new ShareCreateOptions()
     .setMetadata(Collections.singletonMap("share", "metadata")).setQuotaInGb(1)
     .setAccessTier(ShareAccessTier.HOT), Duration.ofSeconds(1), new Context(key1, value1));

 if (response.getStatusCode() == 409) {
     System.out.println("Already existed.");
 } else {
     System.out.printf("Create completed with status %d%n", response.getStatusCode());
 }

For more information, see the Azure Docs.

Parameters:

options - ShareCreateOptions
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A reactive 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 String createPermission(ShareFilePermission 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

ShareFilePermission permission = new ShareFilePermission().setPermission("filePermission")
     .setPermissionFormat(FilePermissionFormat.BINARY);
 String response1 = shareClient.createPermission(permission);
 System.out.printf("The file permission key is %s", response1);

Parameters:

filePermission - The file permission to get/create.

Returns:

The file permission key associated with the file permission.

createPermission

public String 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

String response = shareClient.createPermission("filePermission");
 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 Response createPermissionWithResponse(ShareFilePermission filePermission, Duration timeout, Context context)

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

ShareFilePermission permission = new ShareFilePermission().setPermission("filePermission")
     .setPermissionFormat(FilePermissionFormat.BINARY);
 Response<String> response1 = shareClient.createPermissionWithResponse(permission, null, Context.NONE);
 System.out.printf("The file permission key is %s", response1.getValue());

Parameters:

filePermission - The file permission to get/create.
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.

Returns:

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

createPermissionWithResponse

public Response createPermissionWithResponse(String filePermission, Context context)

Creates a permission t 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

Response<String> response = shareClient.createPermissionWithResponse("filePermission", Context.NONE);
 System.out.printf("The file permission key is %s", response.getValue());

Parameters:

filePermission - The file permission to get/create.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

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

createSnapshot

public ShareSnapshotInfo 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

ShareSnapshotInfo response = shareClient.createSnapshot();
 System.out.println("Complete creating the share snpashot with snapshot id: " + response.getSnapshot());

For more information, see the Azure Docs.

Returns:

createSnapshotWithResponse

public Response createSnapshotWithResponse(Map metadata, Duration timeout, Context context)

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"

Response<ShareSnapshotInfo> response =
     shareClient.createSnapshotWithResponse(Collections.singletonMap("snpashot", "metadata"),
         Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete creating the share snpashot with snapshot id: " + response.getValue().getSnapshot());

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.
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareSnapshotInfo and status of creation.

createWithResponse

public Response createWithResponse(ShareCreateOptions options, Duration timeout, Context context)

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

Code Samples

Response<ShareInfo> response = shareClient.createWithResponse(new ShareCreateOptions()
         .setMetadata(Collections.singletonMap("share", "metadata")).setQuotaInGb(1)
         .setAccessTier(ShareAccessTier.HOT), Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete creating the shares with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

options - ShareCreateOptions
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareInfo and the status its creation.

createWithResponse

public Response createWithResponse(Map metadata, Integer quotaInGB, Duration timeout, Context context)

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

Code Samples

Create the share with metadata "share:metadata"

Response<ShareInfo> response = shareClient.createWithResponse(Collections.singletonMap("share", "metadata"),
     null, Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete creating the shares with status code: " + response.getStatusCode());

Create the share with a quota of 10 GB

Response<ShareInfo> response = shareClient.createWithResponse(null, 10,
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete creating the shares with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

For more information on updated max file share size values, 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. The default value is 5120. Refer to the Azure Docs for updated values.
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareInfo and the status its creation.

delete

public void delete()

Deletes the share in the storage account

Code Samples

Delete the share

shareClient.delete();
 System.out.println("Completed deleting the share.");

For more information, see the Azure Docs.

deleteDirectory

public void deleteDirectory(String directoryName)

Deletes the specified directory in the share.

Code Samples

Delete the directory "mydirectory"

shareClient.deleteDirectory("mydirectory");
 System.out.println("Completed deleting the directory.");

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

deleteDirectoryIfExists

public boolean deleteDirectoryIfExists(String directoryName)

Deletes the specified directory in the share if it exists.

Code Samples

Delete the directory "mydirectory"

boolean result = shareClient.deleteDirectoryIfExists("mydirectory");
 System.out.println("Directory deleted: " + result);

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory

Returns:

true if the directory is successfully deleted, false if the directory does not exist.

deleteDirectoryIfExistsWithResponse

public Response deleteDirectoryIfExistsWithResponse(String directoryName, Duration timeout, Context context)

Deletes the specified directory in the share if it exists.

Code Samples

Delete the directory "mydirectory"

Response<Boolean> response = shareClient.deleteDirectoryIfExistsWithResponse("mydirectory",
     Duration.ofSeconds(1), new Context(key1, value1));
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers. 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 Response deleteDirectoryWithResponse(String directoryName, Duration timeout, Context context)

Deletes the specified directory in the share.

Code Samples

Delete the directory "mydirectory"

Response<Void> response = shareClient.deleteDirectoryWithResponse("mydirectory",
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete deleting the directory with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

directoryName - Name of the directory
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response that only contains headers and response status code

deleteFile

public void deleteFile(String fileName)

Deletes the specified file in the share.

Code Samples

Delete the file "myfile"

shareClient.deleteFile("myfile");
 System.out.println("Complete deleting the file.");

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file

deleteFileIfExists

public boolean deleteFileIfExists(String fileName)

Deletes the specified file in the share if it exists.

Code Samples

Delete the file "myfile"

boolean result = shareClient.deleteFileIfExists("myfile");
 System.out.println("File deleted: " + result);

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file

Returns:

true if the file is successfully deleted, false if the file does not exist.

deleteFileIfExistsWithResponse

public Response deleteFileIfExistsWithResponse(String fileName, ShareRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified file in the share if it exists.

Code Samples

Delete the file "myfile"

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

 Response<Boolean> response = shareClient.deleteFileIfExistsWithResponse("myfile", requestConditions,
     Duration.ofSeconds(1), new Context(key1, value1));
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file
requestConditions - ShareRequestConditions
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers. 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 Response deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified file in the share.

Code Samples

Delete the file "myfile"

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 Response<Void> response = shareClient.deleteFileWithResponse("myfile", requestConditions,
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete deleting the file with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file
requestConditions - ShareRequestConditions
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response that only contains headers and response status code

deleteFileWithResponse

public Response deleteFileWithResponse(String fileName, Duration timeout, Context context)

Deletes the specified file in the share.

Code Samples

Delete the file "myfile"

Response<Void> response = shareClient.deleteFileWithResponse("myfile",
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete deleting the file with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

fileName - Name of the file
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response that only contains headers and response status code

deleteIfExists

public boolean deleteIfExists()

Deletes the share in the storage account if it exists.

Code Samples

Delete the share

boolean result = shareClient.deleteIfExists();
 System.out.println("Share deleted: " + result);

For more information, see the Azure Docs.

Returns:

true if the share is successfully deleted, false if the share does not exist.

deleteIfExistsWithResponse

public Response deleteIfExistsWithResponse(ShareDeleteOptions options, Duration timeout, Context context)

Deletes the share in the storage account if it exists.

Code Samples

Delete the share

Response<Boolean> response = shareClient.deleteIfExistsWithResponse(new ShareDeleteOptions()
         .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)),
     Duration.ofSeconds(1), new Context(key1, value1));
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

For more information, see the Azure Docs.

Parameters:

options - ShareDeleteOptions
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers. 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 Response deleteWithResponse(ShareDeleteOptions options, Duration timeout, Context context)

Deletes the share in the storage account

Code Samples

Delete the share

Response<Void> response = shareClient.deleteWithResponse(new ShareDeleteOptions()
         .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)),
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete deleting the share with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

options - ShareDeleteOptions
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response that only contains headers and response status code

deleteWithResponse

public Response deleteWithResponse(Duration timeout, Context context)

Deletes the share in the storage account

Code Samples

Delete the share

Response<Void> response = shareClient.deleteWithResponse(Duration.ofSeconds(1), new Context(key1, value1));
 System.out.println("Complete deleting the share with status code: " + response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response that only contains headers and response status code

exists

public Boolean exists()

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

Code Samples

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

Returns:

Flag indicating existence of the share.

existsWithResponse

public Response existsWithResponse(Duration timeout, Context context)

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

Code Samples

Context context = new Context("Key", "Value");
 System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue());

Parameters:

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.

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.

generateSas

public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, 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.

Parameters:

shareServiceSasSignatureValues - ShareServiceSasSignatureValues
stringToSignHandler - For debugging purposes only. Returns the string to sign that was used to generate the signature.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

getAccessPolicy

public PagedIterable getAccessPolicy()

Retrieves stored access policies specified for the share.

Code Samples

List the stored access policies

for (ShareSignedIdentifier result : shareClient.getAccessPolicy()) {
     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 PagedIterable getAccessPolicy(ShareGetAccessPolicyOptions options)

Retrieves stored access policies specified for the share.

Code Samples

List the stored access policies

for (ShareSignedIdentifier result : shareClient
     .getAccessPolicy(new ShareGetAccessPolicyOptions()
         .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)))) {
     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 ShareDirectoryClient getDirectoryClient(String directoryName)

Constructs a ShareDirectoryClient that interacts with the specified directory.

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

Parameters:

directoryName - Name of the directory

Returns:

a ShareDirectoryClient that interacts with the directory in the share

getFileClient

public ShareFileClient getFileClient(String filePath)

Constructs a ShareFileClient 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 ShareFileClient that interacts with the file in the share

getHttpPipeline

public HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Returns:

The pipeline.

getPermission

public String getPermission(String filePermissionKey)

Gets a permission for a given key

Code Samples

String response = shareClient.getPermission("filePermissionKey");
 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.

getPermission

public String getPermission(String filePermissionKey, FilePermissionFormat filePermissionFormat)

Gets a permission for a given key

Code Samples

FilePermissionFormat filePermissionFormat = FilePermissionFormat.BINARY;
 String response2 = shareClient.getPermission("filePermissionKey", filePermissionFormat);
 System.out.printf("The file permission is %s", response2);

Parameters:

filePermissionKey - The file permission key.
filePermissionFormat - Optional. Available for version 2024-11-04 and later. Specifies the format in which the permission is returned. If filePermissionFormat is unspecified or explicitly set to SDDL, the permission will be returned in SSDL format. If filePermissionFormat is explicity set to binary, the permission is returned as a base64 string representing the binary encoding of the permission in self-relative format.

Returns:

The file permission associated with the file permission key.

getPermissionWithResponse

public Response getPermissionWithResponse(String filePermissionKey, Context context)

Gets a permission for a given key.

Code Samples

Response<String> response = shareClient.getPermissionWithResponse("filePermissionKey", Context.NONE);
 System.out.printf("The file permission is %s", response.getValue());

Parameters:

filePermissionKey - The file permission key.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

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

getPermissionWithResponse

public Response getPermissionWithResponse(String filePermissionKey, FilePermissionFormat filePermissionFormat, Duration timeout, Context context)

Gets a permission for a given key.

Code Samples

FilePermissionFormat filePermissionFormat = FilePermissionFormat.BINARY;
 Response<String> response1 = shareClient.getPermissionWithResponse("filePermissionKey",
     filePermissionFormat, null, Context.NONE);
 System.out.printf("The file permission is %s", response1.getValue());

Parameters:

filePermissionKey - The file permission key.
filePermissionFormat - Optional. Available for version 2024-11-04 and later. Specifies the format in which the permission is returned. If filePermissionFormat is unspecified or explicitly set to SDDL, the permission will be returned in SSDL format. If filePermissionFormat is explicity set to binary, the permission is returned as a base64 string representing the binary encoding of the permission in self-relative 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.

Returns:

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

getProperties

public ShareProperties 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

ShareProperties properties = shareClient.getProperties();
 System.out.printf("Share quota: %d, Metadata: %s", properties.getQuota(), properties.getMetadata());

For more information, see the Azure Docs.

Returns:

getPropertiesWithResponse

public Response getPropertiesWithResponse(ShareGetPropertiesOptions options, Duration timeout, Context context)

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

ShareProperties properties = shareClient.getPropertiesWithResponse(new ShareGetPropertiesOptions()
     .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)),
     Duration.ofSeconds(1), new Context(key1, value1)).getValue();
 System.out.printf("Share quota: %d, Metadata: %s", properties.getQuota(), properties.getMetadata());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing ShareProperties with response status code

getPropertiesWithResponse

public Response getPropertiesWithResponse(Duration timeout, Context context)

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

ShareProperties properties = shareClient.getPropertiesWithResponse(
     Duration.ofSeconds(1), new Context(key1, value1)).getValue();
 System.out.printf("Share quota: %d, Metadata: %s", properties.getQuota(), properties.getMetadata());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing ShareProperties with response status code

getRootDirectoryClient

public ShareDirectoryClient getRootDirectoryClient()

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

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

Returns:

a ShareDirectoryClient 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 = shareClient.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 ShareClient 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 ShareClient used to interact with the specific snapshot.

getSnapshotId

public String getSnapshotId()

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

Code Samples

Get the share snapshot id.

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

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

Returns:

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

getStatistics

public ShareStatistics getStatistics()

Retrieves storage statistics about the share.

Code Samples

Retrieve the storage statistics

ShareStatistics response = shareClient.getStatistics();
 System.out.printf("The share is using %d GB", response.getShareUsageInGB());

For more information, see the Azure Docs.

Returns:

The storage ShareStatistics

getStatisticsWithResponse

public Response getStatisticsWithResponse(ShareGetStatisticsOptions options, Duration timeout, Context context)

Retrieves storage statistics about the share.

Code Samples

Retrieve the storage statistics

Response<ShareStatistics> response = shareClient.getStatisticsWithResponse(
     new ShareGetStatisticsOptions().setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)),
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.printf("The share is using %d GB", response.getValue().getShareUsageInGB());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareStatistics

getStatisticsWithResponse

public Response getStatisticsWithResponse(Duration timeout, Context context)

Retrieves storage statistics about the share.

Code Samples

Retrieve the storage statistics

Response<ShareStatistics> response = shareClient.getStatisticsWithResponse(
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.printf("The share is using %d GB", response.getValue().getShareUsageInGB());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareStatistics

setAccessPolicy

public ShareInfo 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);

 shareClient.setAccessPolicy(Collections.singletonList(permission));
 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 Response setAccessPolicyWithResponse(ShareSetAccessPolicyOptions options, Duration timeout, Context context)

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);

 Response<ShareInfo> response = shareClient.setAccessPolicyWithResponse(
     new ShareSetAccessPolicyOptions().setPermissions(Collections.singletonList(permission))
         .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)),
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.printf("Setting access policies completed with status code %d", response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareInfo with headers and response status code

setAccessPolicyWithResponse

public Response setAccessPolicyWithResponse(List permissions, Duration timeout, Context context)

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);

 Response<ShareInfo> response = shareClient.setAccessPolicyWithResponse(Collections.singletonList(permission),
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.printf("Setting access policies completed with status code %d", response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

permissions - Access policies to set on the queue
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the ShareInfo with headers and response status code

setMetadata

public ShareInfo 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"

shareClient.setMetadata(Collections.singletonMap("share", "updatedMetadata"));
 System.out.println("Setting the share metadata.");

Clear the metadata of the share

shareClient.setMetadata(null);
 System.out.println("Clear 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 Response setMetadataWithResponse(ShareSetMetadataOptions options, Duration timeout, Context context)

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"

Response<ShareInfo> response = shareClient.setMetadataWithResponse(new ShareSetMetadataOptions()
         .setMetadata(Collections.singletonMap("share", "updatedMetadata"))
         .setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId)),
     Duration.ofSeconds(1),
     new Context(key1, value1));
 System.out.printf("Setting the share metadata completed with status code %d", response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing ShareProperties with response status code

setMetadataWithResponse

public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context)

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"

Response<ShareInfo> response = shareClient.setMetadataWithResponse(
     Collections.singletonMap("share", "updatedMetadata"), Duration.ofSeconds(1),
     new Context(key1, value1));
 System.out.printf("Setting the share metadata completed with status code %d", response.getStatusCode());

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
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing ShareProperties with response status code

setProperties

public ShareInfo setProperties(ShareSetPropertiesOptions options)

Sets the share's properties.

Code Samples

System.out.println("Setting the share access tier completed." + shareClient.setProperties(
     new ShareSetPropertiesOptions().setAccessTier(ShareAccessTier.HOT).setQuotaInGb(1024)));

For more information, see the Azure Docs.

Parameters:

Returns:

setPropertiesWithResponse

public Response setPropertiesWithResponse(ShareSetPropertiesOptions options, Duration timeout, Context context)

Sets the share's properties.

Code Samples

Response<ShareInfo> response = shareClient.setPropertiesWithResponse(
     new ShareSetPropertiesOptions().setAccessTier(ShareAccessTier.HOT).setQuotaInGb(1024),
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.printf("Setting the share access tier completed with status code %d", response.getStatusCode());

For more information, see the Azure Docs.

Parameters:

timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing ShareInfo with response status code

setQuota

@Deprecated
public ShareInfo 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

System.out.println("Setting the share quota completed." + shareClient.setQuota(1024));

For more information, see the Azure Docs.

For more information on updated max file share size values, see the Azure Docs.

Parameters:

quotaInGB - Size in GB to limit the share's growth. The default value is 5120. Refer to the Azure Docs for updated values.

Returns:

setQuotaWithResponse

@Deprecated
public Response setQuotaWithResponse(int quotaInGB, Duration timeout, Context context)

Deprecated

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

Code Samples

Set the quota to 1024 GB

Response<ShareInfo> response = shareClient.setQuotaWithResponse(1024,
     Duration.ofSeconds(1), new Context(key1, value1));
 System.out.printf("Setting the share quota completed with status code %d", response.getStatusCode());

For more information, see the Azure Docs.

For more information on updated max file share size values, see the Azure Docs.

Parameters:

quotaInGB - Size in GB to limit the share's growth. The default value is 5120. Refer to the Azure Docs for updated values.
timeout - An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing ShareInfo with response status code

Applies to