Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/storage/azure-storage-file-share/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 12.7.0-beta.2 (Unreleased)

- Added support for setting access tier on a share through ShareClient.create, ShareClient.setAccessTier.
- Added support for getting access tier on a share through ShareClient.getProperties, ShareServiceClient.listShares

## 12.7.0-beta.1 (2020-10-01)
- Added support for the 2020-02-10 service version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.azure.storage.file.share.implementation.models.SharesGetPropertiesResponse;
import com.azure.storage.file.share.implementation.models.SharesGetStatisticsResponse;
import com.azure.storage.file.share.implementation.util.ShareSasImplUtil;
import com.azure.storage.file.share.models.ShareAccessTier;
import com.azure.storage.file.share.models.ShareErrorCode;
import com.azure.storage.file.share.models.ShareFileHttpHeaders;
import com.azure.storage.file.share.models.ShareInfo;
Expand All @@ -35,11 +36,13 @@
import com.azure.storage.file.share.models.ShareSnapshotInfo;
import com.azure.storage.file.share.models.ShareStatistics;
import com.azure.storage.file.share.models.ShareStorageException;
import com.azure.storage.file.share.options.ShareCreateOptions;
import com.azure.storage.file.share.options.ShareDeleteOptions;
import com.azure.storage.file.share.options.ShareGetAccessPolicyOptions;
import com.azure.storage.file.share.options.ShareGetPropertiesOptions;
import com.azure.storage.file.share.options.ShareGetStatisticsOptions;
import com.azure.storage.file.share.options.ShareSetAccessPolicyOptions;
import com.azure.storage.file.share.options.ShareSetAccessTierOptions;
import com.azure.storage.file.share.options.ShareSetMetadataOptions;
import com.azure.storage.file.share.options.ShareSetQuotaOptions;
import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues;
Expand Down Expand Up @@ -235,7 +238,7 @@ Mono<Response<Boolean>> existsWithResponse(Context context) {
*/
public Mono<ShareInfo> create() {
try {
return createWithResponse(null, null).flatMap(FluxUtil::toMono);
return createWithResponse(null).flatMap(FluxUtil::toMono);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -266,17 +269,44 @@ public Mono<ShareInfo> create() {
*/
public Mono<Response<ShareInfo>> createWithResponse(Map<String, String> metadata, Integer quotaInGB) {
try {
return withContext(context -> createWithResponse(metadata, quotaInGB, context));
return withContext(context -> createWithResponse(new ShareCreateOptions().setMetadata(metadata)
.setQuotaInGb(quotaInGB), context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

Mono<Response<ShareInfo>> createWithResponse(Map<String, String> metadata, Integer quotaInGB, Context context) {
/**
* Creates the share in the storage account with the specified options.
*
* <p><strong>Code Samples</strong></p>
*
* <p>Create the share with optional parameters</p>
*
* {@codesnippet com.azure.storage.file.share.ShareAsyncClient.createWithResponse#ShareCreateOptions}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/create-share">Azure Docs</a>.</p>
*
* @param options {@link ShareCreateOptions}
* @return A response containing information about the {@link ShareInfo share} and the status its creation.
* @throws ShareStorageException If the share already exists with different metadata or {@code quotaInGB} is outside
* the allowed range.
*/
public Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options) {
try {
return withContext(context -> createWithResponse(options, context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options, Context context) {
context = context == null ? Context.NONE : context;
options = options == null ? new ShareCreateOptions() : options;
return azureFileStorageClient.shares()
.createWithRestResponseAsync(shareName, null, metadata, quotaInGB,
context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE))
.createWithRestResponseAsync(shareName, null, options.getMetadata(), options.getQuotaInGb(),
options.getAccessTier(), context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE))
.map(this::mapToShareInfoResponse);
}

Expand Down Expand Up @@ -572,19 +602,66 @@ public Mono<Response<ShareInfo>> setQuotaWithResponse(int quotaInGB) {
*/
public Mono<Response<ShareInfo>> setQuotaWithResponse(ShareSetQuotaOptions options) {
try {
return withContext(context -> setQuotaWithResponse(options, context));
StorageImplUtils.assertNotNull("options", options);
return withContext(context -> setPropertiesWithResponse(options.getQuotaInGb(), null,
options.getRequestConditions(), context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

Mono<Response<ShareInfo>> setQuotaWithResponse(ShareSetQuotaOptions options, Context context) {
StorageImplUtils.assertNotNull("options", options);
ShareRequestConditions requestConditions = options.getRequestConditions() == null
? new ShareRequestConditions() : options.getRequestConditions();
/**
* Sets the share's access tier.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.share.ShareAsyncClient.setAccessTier#ShareAccessTier}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties">Azure Docs</a>.</p>
*
* @param accessTier {@link ShareAccessTier}
* @return The {@link ShareInfo information about the share}
*/
public Mono<ShareInfo> setAccessTier(ShareAccessTier accessTier) {
try {
return setAccessTierWithResponse(new ShareSetAccessTierOptions(accessTier))
.map(Response::getValue);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

/**
* Sets the share's access tier.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.share.ShareAsyncClient.setAccessTierWithResponse#ShareSetAccessTierOptions}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties">Azure Docs</a>.</p>
*
* @param options {@link ShareSetQuotaOptions}
* @return A response containing the {@link ShareInfo information about the share} with headers and response status
* code
*/
public Mono<Response<ShareInfo>> setAccessTierWithResponse(ShareSetAccessTierOptions options) {
try {
StorageImplUtils.assertNotNull("options", options);
return withContext(context -> setPropertiesWithResponse(null, options.getAccessTier(),
options.getRequestConditions(), context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

Mono<Response<ShareInfo>> setPropertiesWithResponse(Integer quotaInGb, ShareAccessTier accessTier,
ShareRequestConditions requestConditions, Context context) {
requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions;
context = context == null ? Context.NONE : context;
return azureFileStorageClient.shares().setQuotaWithRestResponseAsync(shareName, null,
options.getQuotaInGb(), requestConditions.getLeaseId(),
return azureFileStorageClient.shares().setPropertiesWithRestResponseAsync(shareName, null,
quotaInGb, accessTier, requestConditions.getLeaseId(),
context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE))
.map(this::mapToShareInfoResponse);
}
Expand Down Expand Up @@ -1431,7 +1508,10 @@ private Response<ShareProperties> mapGetPropertiesResponse(SharesGetPropertiesRe
.setProvisionedIops(headers.getProvisionedIops())
.setLeaseDuration(headers.getLeaseDuration())
.setLeaseState(headers.getLeaseState())
.setLeaseStatus(headers.getLeaseStatus());
.setLeaseStatus(headers.getLeaseStatus())
.setAccessTier(headers.getAccessTier())
.setAccessTierChangeTime(headers.getAccessTierChangeTime())
.setAccessTierTransitionState(headers.getAccessTierTransitionState());

return new SimpleResponse<>(response, shareProperties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.core.util.Context;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.file.share.models.ShareAccessTier;
import com.azure.storage.file.share.models.ShareFileHttpHeaders;
import com.azure.storage.file.share.models.ShareRequestConditions;
import com.azure.storage.file.share.models.ShareSignedIdentifier;
Expand All @@ -19,11 +20,13 @@
import com.azure.storage.file.share.models.ShareProperties;
import com.azure.storage.file.share.models.ShareSnapshotInfo;
import com.azure.storage.file.share.models.ShareStatistics;
import com.azure.storage.file.share.options.ShareCreateOptions;
import com.azure.storage.file.share.options.ShareDeleteOptions;
import com.azure.storage.file.share.options.ShareGetAccessPolicyOptions;
import com.azure.storage.file.share.options.ShareGetPropertiesOptions;
import com.azure.storage.file.share.options.ShareGetStatisticsOptions;
import com.azure.storage.file.share.options.ShareSetAccessPolicyOptions;
import com.azure.storage.file.share.options.ShareSetAccessTierOptions;
import com.azure.storage.file.share.options.ShareSetMetadataOptions;
import com.azure.storage.file.share.options.ShareSetQuotaOptions;
import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues;
Expand Down Expand Up @@ -203,7 +206,33 @@ public ShareInfo create() {
*/
public Response<ShareInfo> createWithResponse(Map<String, String> metadata, Integer quotaInGB, Duration timeout,
Context context) {
Mono<Response<ShareInfo>> response = client.createWithResponse(metadata, quotaInGB, context);
Mono<Response<ShareInfo>> response = client.createWithResponse(new ShareCreateOptions().setQuotaInGb(quotaInGB)
.setMetadata(metadata), context);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
* Creates the share in the storage account with the specified options.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet ShareClient.createWithResponse#ShareCreateOptions-Duration-Context}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/create-share">Azure Docs</a>.</p>
*
* @param options {@link ShareCreateOptions}
* @param timeout An optional timeout applied to the operation. If a response is not returned before the timeout
* concludes a {@link RuntimeException} will be thrown.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing the {@link ShareInfo information about the share} and the status its creation.
* @throws ShareStorageException If the share already exists with different metadata or {@code quotaInGB} is outside
* the allowed range.
* @throws RuntimeException if the operation doesn't complete before the timeout concludes.
*/
public Response<ShareInfo> createWithResponse(ShareCreateOptions options, Duration timeout,
Context context) {
Mono<Response<ShareInfo>> response = client.createWithResponse(options, context);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

Expand Down Expand Up @@ -406,7 +435,7 @@ public Response<ShareProperties> getPropertiesWithResponse(ShareGetPropertiesOpt
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties">Azure Docs</a>.</p>
*
* @param quotaInGB Size in GB to limit the share's growth. The quota in GB must be between 1 and 5120.
* @return The {@link ShareProperties properties of the share}
* @return The {@link ShareInfo information about the share}
* @throws ShareStorageException If the share doesn't exist or {@code quotaInGB} is outside the allowed bounds
*/
public ShareInfo setQuota(int quotaInGB) {
Expand All @@ -429,7 +458,7 @@ public ShareInfo setQuota(int quotaInGB) {
* @param timeout An optional timeout applied to the operation. If a response is not returned before the timeout
* concludes a {@link RuntimeException} will be thrown.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing {@link ShareProperties properties of the share} with response status code
* @return A response containing {@link ShareInfo information about the share} with response status code
* @throws ShareStorageException If the share doesn't exist or {@code quotaInGB} is outside the allowed bounds
* @throws RuntimeException if the operation doesn't complete before the timeout concludes.
*/
Expand All @@ -453,12 +482,56 @@ public Response<ShareInfo> setQuotaWithResponse(int quotaInGB, Duration timeout,
* @param timeout An optional timeout applied to the operation. If a response is not returned before the timeout
* concludes a {@link RuntimeException} will be thrown.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing {@link ShareProperties properties of the share} with response status code
* @return A response containing {@link ShareInfo information about the share} with response status code
* @throws ShareStorageException If the share doesn't exist or {@code quotaInGB} is outside the allowed bounds
* @throws RuntimeException if the operation doesn't complete before the timeout concludes.
*/
public Response<ShareInfo> setQuotaWithResponse(ShareSetQuotaOptions options, Duration timeout, Context context) {
Mono<Response<ShareInfo>> response = client.setQuotaWithResponse(options, context);
StorageImplUtils.assertNotNull("options", options);
Mono<Response<ShareInfo>> response = client.setPropertiesWithResponse(options.getQuotaInGb(), null,
options.getRequestConditions(), context);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
* Sets the access tier of a share.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet ShareClient.setAccessTier#ShareAccessTier}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties">Azure Docs</a>.</p>
*
* @param accessTier {@link ShareAccessTier}
* @return The {@link ShareInfo information about the share}
*/
public ShareInfo setAccessTier(ShareAccessTier accessTier) {
return setAccessTierWithResponse(new ShareSetAccessTierOptions(accessTier), null, Context.NONE)
.getValue();
}

/**
* Sets the access tier of a share.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.share.ShareClient.setAccessTierWithResponse#ShareSetAccessTierOptions-Duration-Context}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties">Azure Docs</a>.</p>
*
* @param options {@link ShareSetAccessTierOptions}
* @param timeout An optional timeout applied to the operation. If a response is not returned before the timeout
* concludes a {@link RuntimeException} will be thrown.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing {@link ShareInfo information about the share} with response status code
*/
public Response<ShareInfo> setAccessTierWithResponse(ShareSetAccessTierOptions options, Duration timeout,
Context context) {
StorageImplUtils.assertNotNull("options", options);
Mono<Response<ShareInfo>> response = client.setPropertiesWithResponse(null, options.getAccessTier(),
options.getRequestConditions(), context);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

Expand Down
Loading