Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set tier on upload/copy; Rehydrate Priority #5229

Merged
merged 12 commits into from
Sep 9, 2019
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public AppendBlobItem create() {
* @return The information of the created appended blob.
*/
public AppendBlobItem create(BlobHTTPHeaders headers, Metadata metadata,
BlobAccessConditions accessConditions, Duration timeout) {
BlobAccessConditions accessConditions, Duration timeout) {
return createWithResponse(headers, metadata, accessConditions, timeout, Context.NONE).value();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.azure.storage.blob.implementation.AzureBlobStorageBuilder;
import com.azure.storage.blob.implementation.AzureBlobStorageImpl;
import com.azure.storage.blob.models.AccessTier;
import com.azure.storage.blob.models.AccessTierOptional;
import com.azure.storage.blob.models.AccessTierRequired;
import com.azure.storage.blob.models.BlobAccessConditions;
import com.azure.storage.blob.models.BlobHTTPHeaders;
Expand All @@ -23,6 +24,7 @@
import com.azure.storage.blob.models.LeaseAccessConditions;
import com.azure.storage.blob.models.Metadata;
import com.azure.storage.blob.models.ModifiedAccessConditions;
import com.azure.storage.blob.models.RehydratePriority;
import com.azure.storage.blob.models.ReliableDownloadOptions;
import com.azure.storage.blob.models.SourceModifiedAccessConditions;
import com.azure.storage.blob.models.StorageAccountInfo;
Expand Down Expand Up @@ -232,37 +234,45 @@ Mono<Response<Boolean>> existsWithResponse(Context context) {
* @return A reactive response containing the copy ID for the long running operation.
*/
public Mono<String> startCopyFromURL(URL sourceURL) {
return startCopyFromURLWithResponse(sourceURL, null, null, null).flatMap(FluxUtil::toMono);
return startCopyFromURLWithResponse(sourceURL, null, null, null, null, null).flatMap(FluxUtil::toMono);
}

/**
* Copies the data at the source URL to a blob.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.BlobAsyncClient.startCopyFromURLWithResponse#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions}
* {@codesnippet com.azure.storage.blob.BlobAsyncClient.startCopyFromURLWithResponse#URL-Metadata-AccessTier-RehydratePriority-ModifiedAccessConditions-BlobAccessConditions}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/rest/api/storageservices/copy-blob">Azure Docs</a></p>
*
* @param sourceURL The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
* @param metadata {@link Metadata}
* @param tier {@link AccessTier} for the destination blob.
* @param priority {@link RehydratePriority} for rehydrating the blob.
* @param sourceModifiedAccessConditions {@link ModifiedAccessConditions} against the source. Standard HTTP Access
* conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions
* related to when the blob was changed relative to the given request. The request will fail if the specified
* condition is not satisfied.
* @param destAccessConditions {@link BlobAccessConditions} against the destination.
jaschrep-msft marked this conversation as resolved.
Show resolved Hide resolved
* @return A reactive response containing the copy ID for the long running operation.
*/
public Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions) {
return withContext(context -> startCopyFromURLWithResponse(sourceURL, metadata, sourceModifiedAccessConditions, destAccessConditions, context));
public Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata metadata, AccessTier tier,
RehydratePriority priority, ModifiedAccessConditions sourceModifiedAccessConditions,
BlobAccessConditions destAccessConditions) {
return withContext(context -> startCopyFromURLWithResponse(sourceURL, metadata, tier, priority,
sourceModifiedAccessConditions, destAccessConditions, context));
}

Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions, Context context) {
Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata metadata, AccessTier tier,
RehydratePriority priority, ModifiedAccessConditions sourceModifiedAccessConditions,
BlobAccessConditions destAccessConditions, Context context) {
metadata = metadata == null ? new Metadata() : metadata;
sourceModifiedAccessConditions = sourceModifiedAccessConditions == null
? new ModifiedAccessConditions() : sourceModifiedAccessConditions;
destAccessConditions = destAccessConditions == null ? new BlobAccessConditions() : destAccessConditions;
AccessTierOptional tierOp = tier == null ? null : AccessTierOptional.fromString(tier.toString());

// We want to hide the SourceAccessConditions type from the user for consistency's sake, so we convert here.
SourceModifiedAccessConditions sourceConditions = new SourceModifiedAccessConditions()
Expand All @@ -272,7 +282,7 @@ Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata meta
.sourceIfNoneMatch(sourceModifiedAccessConditions.ifNoneMatch());

return postProcessResponse(this.azureBlobStorage.blobs().startCopyFromURLWithRestResponseAsync(
null, null, sourceURL, null, metadata, null, null, null, sourceConditions,
null, null, sourceURL, null, metadata, tierOp, priority, null, sourceConditions,
destAccessConditions.modifiedAccessConditions(), destAccessConditions.leaseAccessConditions(), context))
.map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().copyId()));
}
Expand Down Expand Up @@ -335,37 +345,43 @@ Mono<VoidResponse> abortCopyFromURLWithResponse(String copyId, LeaseAccessCondit
* @return A reactive response containing the copy ID for the long running operation.
*/
public Mono<String> copyFromURL(URL copySource) {
return copyFromURLWithResponse(copySource, null, null, null).flatMap(FluxUtil::toMono);
return copyFromURLWithResponse(copySource, null, null, null, null).flatMap(FluxUtil::toMono);
}

/**
* Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.BlobAsyncClient.copyFromURLWithResponse#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions}
* {@codesnippet com.azure.storage.blob.BlobAsyncClient.copyFromURLWithResponse#URL-Metadata-AccessTier-ModifiedAccessConditions-BlobAccessConditions}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob">Azure Docs</a></p>
*
* @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
* @param metadata {@link Metadata}
* @param tier {@link AccessTier} for the destination blob.
* @param sourceModifiedAccessConditions {@link ModifiedAccessConditions} against the source. Standard HTTP Access
* conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions
* related to when the blob was changed relative to the given request. The request will fail if the specified
* condition is not satisfied.
* @param destAccessConditions {@link BlobAccessConditions} against the destination.
jaschrep-msft marked this conversation as resolved.
Show resolved Hide resolved
* @return A reactive response containing the copy ID for the long running operation.
*/
public Mono<Response<String>> copyFromURLWithResponse(URL copySource, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions) {
return withContext(context -> copyFromURLWithResponse(copySource, metadata, sourceModifiedAccessConditions, destAccessConditions, context));
public Mono<Response<String>> copyFromURLWithResponse(URL copySource, Metadata metadata, AccessTier tier,
ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions) {
return withContext(context -> copyFromURLWithResponse(copySource, metadata, tier,
sourceModifiedAccessConditions, destAccessConditions, context));
}

Mono<Response<String>> copyFromURLWithResponse(URL copySource, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions, Context context) {
Mono<Response<String>> copyFromURLWithResponse(URL copySource, Metadata metadata, AccessTier tier,
ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions,
Context context) {
metadata = metadata == null ? new Metadata() : metadata;
sourceModifiedAccessConditions = sourceModifiedAccessConditions == null
? new ModifiedAccessConditions() : sourceModifiedAccessConditions;
destAccessConditions = destAccessConditions == null ? new BlobAccessConditions() : destAccessConditions;
AccessTierOptional tierOp = tier == null ? null : AccessTierOptional.fromString(tier.toString());

// We want to hide the SourceAccessConditions type from the user for consistency's sake, so we convert here.
SourceModifiedAccessConditions sourceConditions = new SourceModifiedAccessConditions()
Expand All @@ -375,7 +391,7 @@ Mono<Response<String>> copyFromURLWithResponse(URL copySource, Metadata metadata
.sourceIfNoneMatch(sourceModifiedAccessConditions.ifNoneMatch());

return postProcessResponse(this.azureBlobStorage.blobs().copyFromURLWithRestResponseAsync(
null, null, copySource, null, metadata, null, null, sourceConditions,
null, null, copySource, null, metadata, tierOp, null, sourceConditions,
destAccessConditions.modifiedAccessConditions(), destAccessConditions.leaseAccessConditions(), context))
.map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().copyId()));
}
Expand Down Expand Up @@ -826,7 +842,7 @@ Mono<Response<BlobAsyncClient>> createSnapshotWithResponse(Metadata metadata, Bl
* @return A reactive response signalling completion.
*/
public Mono<Void> setTier(AccessTier tier) {
return setTierWithResponse(tier, null).flatMap(FluxUtil::toMono);
return setTierWithResponse(tier, null, null).flatMap(FluxUtil::toMono);
}

/**
Expand All @@ -837,26 +853,27 @@ public Mono<Void> setTier(AccessTier tier) {
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.BlobAsyncClient.setTierWithResponse#AccessTier-LeaseAccessConditions}
* {@codesnippet com.azure.storage.blob.BlobAsyncClient.setTierWithResponse#AccessTier-RehydratePriority-LeaseAccessConditions}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier">Azure Docs</a></p>
*
* @param tier The new tier for the blob.
* @param priority Optional priority to set for re-hydrating blobs.
* @param leaseAccessConditions By setting lease access conditions, requests will fail if the provided lease does
* not match the active lease on the blob.
* @return A reactive response signalling completion.
*/
public Mono<VoidResponse> setTierWithResponse(AccessTier tier, LeaseAccessConditions leaseAccessConditions) {
return withContext(context -> setTierWithResponse(tier, leaseAccessConditions, context));
public Mono<VoidResponse> setTierWithResponse(AccessTier tier, RehydratePriority priority, LeaseAccessConditions leaseAccessConditions) {
return withContext(context -> setTierWithResponse(tier, priority, leaseAccessConditions, context));
}

Mono<VoidResponse> setTierWithResponse(AccessTier tier, LeaseAccessConditions leaseAccessConditions, Context context) {
Mono<VoidResponse> setTierWithResponse(AccessTier tier, RehydratePriority priority, LeaseAccessConditions leaseAccessConditions, Context context) {
Utility.assertNotNull("tier", tier);
AccessTierRequired accessTierRequired = AccessTierRequired.fromString(tier.toString());

return postProcessResponse(this.azureBlobStorage.blobs().setTierWithRestResponseAsync(
null, null, accessTierRequired, null, null, null, leaseAccessConditions, context))
null, null, accessTierRequired, null, priority, null, leaseAccessConditions, context))
.map(VoidResponse::new);
}

Expand Down
Loading