Class ShareServiceClient
Instantiating a Synchronous File Service Client
ShareServiceClient client = new ShareServiceClientBuilder() .connectionString("${connectionString}") .endpoint("${endpoint}") .buildClient();
View this
for additional ways to construct the shareServiceAsyncClient.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncreateShare
(String shareName) Creates a share in the storage account with the specified name and returns a ShareClient to interact with it.com.azure.core.http.rest.Response
<ShareClient> createShareWithResponse
(String shareName, ShareCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a share in the storage account with the specified name and options and returns a ShareClient to interact with it.com.azure.core.http.rest.Response
<ShareClient> createShareWithResponse
(String shareName, Map<String, String> metadata, Integer quotaInGB, Duration timeout, com.azure.core.util.Context context) Creates a share in the storage account with the specified name and metadata and returns a ShareClient to interact with it.void
deleteShare
(String shareName) Deletes the share in the storage account with the given namecom.azure.core.http.rest.Response
<Void> deleteShareWithResponse
(String shareName, String snapshot, Duration timeout, com.azure.core.util.Context context) Deletes the specific snapshot of the share in the storage account with the given name.generateAccountSas
(AccountSasSignatureValues accountSasSignatureValues) Generates an account SAS for the Azure Storage account using the specifiedAccountSasSignatureValues
.generateAccountSas
(AccountSasSignatureValues accountSasSignatureValues, com.azure.core.util.Context context) Generates an account SAS for the Azure Storage account using the specifiedAccountSasSignatureValues
.generateAccountSas
(AccountSasSignatureValues accountSasSignatureValues, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates an account SAS for the Azure Storage account using the specifiedAccountSasSignatureValues
.Get associated account name.Get the url of the storage file service client.com.azure.core.http.HttpPipeline
Gets theHttpPipeline
powering this client.Retrieves the properties of the storage account's File service.com.azure.core.http.rest.Response
<ShareServiceProperties> getPropertiesWithResponse
(Duration timeout, com.azure.core.util.Context context) Retrieves the properties of the storage account's File service.Gets the service version the client is using.getShareClient
(String shareName) Constructs a ShareClient that interacts with the specified share.com.azure.core.http.rest.PagedIterable
<ShareItem> Lists all shares in the storage account without their metadata or snapshots.com.azure.core.http.rest.PagedIterable
<ShareItem> listShares
(ListSharesOptions options, Duration timeout, com.azure.core.util.Context context) Lists the shares in the Storage account that pass the options filter.void
setProperties
(ShareServiceProperties properties) Sets the properties for the storage account's File service.com.azure.core.http.rest.Response
<Void> setPropertiesWithResponse
(ShareServiceProperties properties, Duration timeout, com.azure.core.util.Context context) Sets the properties for the storage account's File service.undeleteShare
(String deletedShareName, String deletedShareVersion) Restores a previously deleted share.com.azure.core.http.rest.Response
<ShareClient> undeleteShareWithResponse
(String deletedShareName, String deletedShareVersion, Duration timeout, com.azure.core.util.Context context) Restores a previously deleted share.
-
Method Details
-
getFileServiceUrl
Get the url of the storage file service client.- Returns:
- the url of the Storage File service.
-
getServiceVersion
Gets the service version the client is using.- Returns:
- the service version the client is using.
-
getProperties
Retrieves the properties of the storage account's File service. The properties range from storage analytics and metrics to CORS (Cross-Origin Resource Sharing).Code Samples
Retrieve File service properties
ShareServiceProperties properties = fileServiceClient.getProperties(); System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b", properties.getHourMetrics().isEnabled(), properties.getMinuteMetrics().isEnabled());
For more information, see the Azure Docs.
- Returns:
- Storage account
File service properties
-
getPropertiesWithResponse
public com.azure.core.http.rest.Response<ShareServiceProperties> getPropertiesWithResponse(Duration timeout, com.azure.core.util.Context context) Retrieves the properties of the storage account's File service. The properties range from storage analytics and metrics to CORS (Cross-Origin Resource Sharing).Code Samples
Retrieve File service properties
ShareServiceProperties properties = fileServiceClient.getPropertiesWithResponse( Duration.ofSeconds(1), new Context(key1, value1)).getValue(); System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b", properties.getHourMetrics().isEnabled(), properties.getMinuteMetrics().isEnabled());
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 aRuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A response containing the Storage account
File service properties
with headers and response status code - Throws:
RuntimeException
- if the operation doesn't complete before the timeout concludes.
-
getAccountName
Get associated account name.- Returns:
- account name associated with this storage resource.
-
getHttpPipeline
public com.azure.core.http.HttpPipeline getHttpPipeline()Gets theHttpPipeline
powering this client.- Returns:
- The pipeline.
-
generateAccountSas
Generates an account SAS for the Azure Storage account using the specifiedAccountSasSignatureValues
.Note : The client must be authenticated via
StorageSharedKeyCredential
See
AccountSasSignatureValues
for more information on how to construct an account SAS.Generating an account SAS
The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user read and list access to blob and file shares.
AccountSasPermission permissions = new AccountSasPermission() .setListPermission(true) .setReadPermission(true); AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); AccountSasSignatureValues sasValues = new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); // Client must be authenticated via StorageSharedKeyCredential String sas = fileServiceClient.generateAccountSas(sasValues);
- Parameters:
accountSasSignatureValues
-AccountSasSignatureValues
- Returns:
- A
String
representing the SAS query parameters.
-
generateAccountSas
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, com.azure.core.util.Context context) Generates an account SAS for the Azure Storage account using the specifiedAccountSasSignatureValues
.Note : The client must be authenticated via
StorageSharedKeyCredential
See
AccountSasSignatureValues
for more information on how to construct an account SAS.The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob containers and file shares.
AccountSasPermission permissions = new AccountSasPermission() .setListPermission(true) .setReadPermission(true); AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); AccountSasSignatureValues sasValues = new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); // Client must be authenticated via StorageSharedKeyCredential String sas = fileServiceClient.generateAccountSas(sasValues, new Context("key", "value"));
- Parameters:
accountSasSignatureValues
-AccountSasSignatureValues
context
- Additional context that is passed through the code when generating a SAS.- Returns:
- A
String
representing the SAS query parameters.
-
generateAccountSas
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates an account SAS for the Azure Storage account using the specifiedAccountSasSignatureValues
.Note : The client must be authenticated via
StorageSharedKeyCredential
See
AccountSasSignatureValues
for more information on how to construct an account SAS.- Parameters:
accountSasSignatureValues
-AccountSasSignatureValues
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.
-