public final class ShareServiceAsyncClient extends Object
Instantiating an Asynchronous File Service Client
ShareAsyncClient
client = newShareClientBuilder
() .connectionString("${connectionString}") .endpoint("${endpoint}") .buildAsyncClient();
View this
for additional ways to construct the azureFileStorageClient.
Modifier and Type | Method and Description |
---|---|
Mono<ShareAsyncClient> |
createShare(String shareName)
Creates a share in the storage account with the specified name and returns a ShareAsyncClient to interact with
it.
|
Mono<com.azure.core.http.rest.Response<ShareAsyncClient>> |
createShareWithResponse(String shareName,
Map<String,String> metadata,
Integer quotaInGB)
Creates a share in the storage account with the specified name, metadata, and quota and returns a
ShareAsyncClient to interact with it.
|
Mono<Void> |
deleteShare(String shareName)
Deletes the share in the storage account with the given name.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteShareWithResponse(String shareName,
String snapshot)
Deletes the specific snapshot of the share in the storage account with the given name.
|
String |
generateAccountSas(AccountSasSignatureValues accountSasSignatureValues)
Generates an account SAS for the Azure Storage account using the specified
AccountSasSignatureValues . |
String |
getAccountName()
Get associated account name.
|
String |
getFileServiceUrl()
Get the url of the storage file service client.
|
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
Mono<ShareServiceProperties> |
getProperties()
Retrieves the properties of the storage account's File service.
|
Mono<com.azure.core.http.rest.Response<ShareServiceProperties>> |
getPropertiesWithResponse()
Retrieves the properties of the storage account's File service.
|
ShareServiceVersion |
getServiceVersion()
Gets the service version the client is using.
|
ShareAsyncClient |
getShareAsyncClient(String shareName)
Constructs a ShareAsyncClient that interacts with the specified share.
|
ShareAsyncClient |
getShareAsyncClient(String shareName,
String snapshot)
Constructs a ShareAsyncClient that interacts with the specified share.
|
com.azure.core.http.rest.PagedFlux<ShareItem> |
listShares()
Lists all shares in the storage account without their metadata or snapshots.
|
com.azure.core.http.rest.PagedFlux<ShareItem> |
listShares(ListSharesOptions options)
Lists the shares in the Storage account that pass the options filter.
|
Mono<Void> |
setProperties(ShareServiceProperties properties)
Sets the properties for the storage account's File service.
|
Mono<com.azure.core.http.rest.Response<Void>> |
setPropertiesWithResponse(ShareServiceProperties properties)
Sets the properties for the storage account's File service.
|
public String getFileServiceUrl()
public ShareServiceVersion getServiceVersion()
public ShareAsyncClient getShareAsyncClient(String shareName)
If the share doesn't exist in the storage account create
in the
azureFileStorageClient will
need to be called before interaction with the share can happen.
shareName
- Name of the sharepublic ShareAsyncClient getShareAsyncClient(String shareName, String snapshot)
If the share doesn't exist in the storage account create
in the
azureFileStorageClient will
need to be called before interaction with the share can happen.
shareName
- Name of the sharesnapshot
- Snapshot ID of the sharepublic com.azure.core.http.rest.PagedFlux<ShareItem> listShares()
Code Samples
List all shares in the account
fileServiceAsyncClient.listShares().subscribe( shareItem ->System
.out.printf("Share %s exists in the account", shareItem.getName()), error ->System
.err.print(error.toString()), () ->System
.out.println("Complete listing the shares!") );
For more information, see the Azure Docs.
Shares
in the storage account without their metadata or snapshotspublic com.azure.core.http.rest.PagedFlux<ShareItem> listShares(ListSharesOptions options)
Set starts with name filter using prefix
to filter shares that
are
listed.
Pass true to includeMetadata
to have metadata returned
for
the shares.
Pass true to includeSnapshots
to have snapshots of the
shares listed.
Code Samples
List all shares that begin with "azure"
fileServiceAsyncClient.listShares(newListSharesOptions
().setPrefix("azure")).subscribe( shareItem ->System
.out.printf("Share %s exists in the account", shareItem.getName()), error ->System
.err.print(error.toString()), () ->System
.out.println("Complete listing the shares!") );
List all shares including their snapshots and metadata
fileServiceAsyncClient.listShares(newListSharesOptions
().setIncludeMetadata(true).setIncludeSnapshots(true)) .subscribe( shareItem ->System
.out.printf("Share %s exists in the account", shareItem.getName()), error ->System
.err.print(error.toString()), () ->System
.out.println("Complete listing the shares!") );
For more information, see the Azure Docs.
options
- Options for listing sharesShares
in the storage account that satisfy the filter requirementspublic Mono<ShareServiceProperties> getProperties()
Code Samples
Retrieve File service properties
fileServiceAsyncClient.getProperties()
.subscribe(properties -> {
System
.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b",
properties.getHourMetrics().isEnabled(), properties.getMinuteMetrics().isEnabled());
});
For more information, see the Azure Docs.
File service properties
public Mono<com.azure.core.http.rest.Response<ShareServiceProperties>> getPropertiesWithResponse()
Code Samples
Retrieve File service properties
fileServiceAsyncClient.getPropertiesWithResponse()
.subscribe(properties -> System
.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b",
properties.getValue().getHourMetrics().isEnabled(),
properties.getValue().getMinuteMetrics().isEnabled()));
For more information, see the Azure Docs.
File service properties
public Mono<Void> setProperties(ShareServiceProperties properties)
null
value for CORS
. To disable all CORS in the Queue service pass an empty list for CORS
.
Code Sample
Enable Minute and Hour Metrics
fileServiceAsyncClient.getProperties().subscribe(properties -> {
properties.getMinuteMetrics().setEnabled(true);
properties.getHourMetrics().setEnabled(true);
fileServiceAsyncClient.setProperties(properties)
.subscribe(r -> System
.out.println("Setting File service properties completed."));
});
For more information, see the Azure Docs.
properties
- Storage account File service propertiesShareStorageException
- When one of the following is true
allowed headers
, exposed headers
, or allowed origins
exceeds 256 characters.
Allowed methods
isn't DELETE, GET, HEAD, MERGE, POST, OPTIONS, or
PUTpublic Mono<com.azure.core.http.rest.Response<Void>> setPropertiesWithResponse(ShareServiceProperties properties)
null
value for CORS
. To disable all CORS in the Queue service pass an empty list for CORS
.
Code Sample
Clear CORS in the File service
fileServiceAsyncClient.getProperties().subscribe(properties -> { properties.setCors(Collections
.emptyList()); fileServiceAsyncClient.setPropertiesWithResponse(properties).subscribe(response ->System
.out.printf("Setting File service properties completed with status code %d", response.getStatusCode())); });
Enable Minute and Hour Metrics
fileServiceAsyncClient.getPropertiesWithResponse().subscribe(response -> {ShareServiceProperties
properties = response.getValue(); properties.getMinuteMetrics().setEnabled(true); properties.getHourMetrics().setEnabled(true); fileServiceAsyncClient.setPropertiesWithResponse(properties).subscribe(r ->System
.out.printf("Setting File service properties completed with status code %d", r.getStatusCode())); });
For more information, see the Azure Docs.
properties
- Storage account File service propertiesShareStorageException
- When one of the following is true
allowed headers
, exposed headers
, or allowed origins
exceeds 256 characters.
Allowed methods
isn't DELETE, GET, HEAD, MERGE, POST, OPTIONS, or
PUTpublic Mono<ShareAsyncClient> createShare(String shareName)
Code Samples
Create the share "test"
fileServiceAsyncClient.createShare("myshare").subscribe( response -> { }, error ->System
.err.print(error.toString()), () ->System
.out.println("Complete creating the share!") );
For more information, see the Azure Docs.
shareName
- Name of the shareShareAsyncClient
ShareStorageException
- If a share with the same name already existspublic Mono<com.azure.core.http.rest.Response<ShareAsyncClient>> createShareWithResponse(String shareName, Map<String,String> metadata, Integer quotaInGB)
Code Samples
Create the share "test" with metadata "share:metadata"
fileServiceAsyncClient.createShareWithResponse("test",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 "test" with a quota of 10 GB
fileServiceAsyncClient.createShareWithResponse("test", 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.
shareName
- Name of the sharemetadata
- Optional metadata to associate with the sharequotaInGB
- 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.ShareAsyncClient
and the status of creating the share.ShareStorageException
- If a share with the same name already exists or quotaInGB
is outside the
allowed range.public Mono<Void> deleteShare(String shareName)
Code Samples
Delete the share "test"
fileServiceAsyncClient.deleteShare("test").doOnSuccess(
response -> System
.out.println("Deleting the share completed.")
);
For more information, see the Azure Docs.
shareName
- Name of the shareShareStorageException
- If the share doesn't existpublic Mono<com.azure.core.http.rest.Response<Void>> deleteShareWithResponse(String shareName, String snapshot)
Code Samples
Delete the snapshot of share "test" that was created at current time.
OffsetDateTime
midnight =OffsetDateTime
.of(LocalDateTime
.now(),ZoneOffset
.UTC); fileServiceAsyncClient.deleteShareWithResponse("test", midnight.toString()) .subscribe(response ->System
.out.printf("Deleting the snapshot completed with status code %d", response.getStatusCode()));
For more information, see the Azure Docs.
shareName
- Name of the sharesnapshot
- Identifier of the snapshotShareStorageException
- If the share doesn't exist or the snapshot doesn't existpublic String getAccountName()
public com.azure.core.http.HttpPipeline getHttpPipeline()
HttpPipeline
powering this client.public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues)
AccountSasSignatureValues
.
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 = newAccountSasPermission
() .setListPermission(true) .setReadPermission(true);AccountSasResourceType
resourceTypes = newAccountSasResourceType
().setContainer(true);AccountSasService
services = newAccountSasService
().setBlobAccess(true).setFileAccess(true);OffsetDateTime
expiryTime =OffsetDateTime
.now().plus(Duration
.ofDays(2));AccountSasSignatureValues
sasValues = newAccountSasSignatureValues
(expiryTime, permissions, services, resourceTypes); // Client must be authenticated via StorageSharedKeyCredentialString
sas = fileServiceAsyncClient.generateAccountSas(sasValues);
accountSasSignatureValues
- AccountSasSignatureValues
String
representing all SAS query parameters.Copyright © 2020 Microsoft Corporation. All rights reserved.