diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index 0eab682c039d0..74127d47445a2 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -14,6 +14,7 @@ import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRange; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.BlockBlobItem; @@ -515,16 +516,19 @@ buffers is not a common scenario for async like it is in sync (and we already bu final BlobRequestConditions requestConditions = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); final boolean computeMd5 = options.isComputeMd5(); + final BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); + final Boolean legalHold = options.isLegalHold(); BlockBlobAsyncClient blockBlobAsyncClient = getBlockBlobAsyncClient(); Function, Mono>> uploadInChunksFunction = (stream) -> uploadInChunks(blockBlobAsyncClient, stream, parallelTransferOptions, headers, metadata, tags, - tier, requestConditions, computeMd5); + tier, requestConditions, computeMd5, immutabilityPolicy, legalHold); BiFunction, Long, Mono>> uploadFullBlobFunction = (stream, length) -> uploadFullBlob(blockBlobAsyncClient, stream, length, parallelTransferOptions, - headers, metadata, tags, tier, requestConditions, computeMd5); + headers, metadata, tags, tier, requestConditions, computeMd5, immutabilityPolicy, legalHold); Flux data = options.getDataFlux() == null ? Utility.convertStreamToByteBuffer( options.getDataStream(), options.getLength(), @@ -541,7 +545,8 @@ buffers is not a common scenario for async like it is in sync (and we already bu private Mono> uploadFullBlob(BlockBlobAsyncClient blockBlobAsyncClient, Flux data, long length, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map metadata, Map tags, AccessTier tier, - BlobRequestConditions requestConditions, boolean computeMd5) { + BlobRequestConditions requestConditions, boolean computeMd5, BlobImmutabilityPolicy immutabilityPolicy, + Boolean legalHold) { /* Note that there is no need to buffer here as the flux returned by the size gate in this case is created @@ -559,14 +564,17 @@ private Mono> uploadFullBlob(BlockBlobAsyncClient blockB .setTags(tags) .setTier(tier) .setRequestConditions(requestConditions) - .setContentMd5(fluxMd5Wrapper.getMd5())) + .setContentMd5(fluxMd5Wrapper.getMd5()) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(legalHold)) .flatMap(blockBlobAsyncClient::uploadWithResponse); } private Mono> uploadInChunks(BlockBlobAsyncClient blockBlobAsyncClient, Flux data, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map metadata, Map tags, AccessTier tier, - BlobRequestConditions requestConditions, boolean computeMd5) { + BlobRequestConditions requestConditions, boolean computeMd5, BlobImmutabilityPolicy immutabilityPolicy, + Boolean legalHold) { // TODO: Sample/api reference // See ProgressReporter for an explanation on why this lock is necessary and why we use AtomicLong. AtomicLong totalProgress = new AtomicLong(); @@ -609,7 +617,8 @@ private Mono> uploadInChunks(BlockBlobAsyncClient blockB .flatMap(ids -> blockBlobAsyncClient.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(ids) .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(tier) - .setRequestConditions(requestConditions))); + .setRequestConditions(requestConditions).setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(legalHold))); } /** diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java index 51be77a1aad5c..99e495de8aea8 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java @@ -505,7 +505,7 @@ Mono> getPropertiesWithResponse(String leaseId hd.getLastModified(), hd.getXMsLeaseDuration(), hd.getXMsLeaseState(), hd.getXMsLeaseStatus(), hd.getXMsBlobPublicAccess(), Boolean.TRUE.equals(hd.isXMsHasImmutabilityPolicy()), Boolean.TRUE.equals(hd.isXMsHasLegalHold()), hd.getXMsDefaultEncryptionScope(), - hd.isXMsDenyEncryptionScopeOverride()); + hd.isXMsDenyEncryptionScopeOverride(), hd.isXMsImmutableStorageWithVersioningEnabled()); return new SimpleResponse<>(rb, properties); }); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java index e506f577b69dc..386b7af2e9d63 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java @@ -9,6 +9,8 @@ import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AzureSasCredentialPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.util.ClientOptions; @@ -25,6 +27,7 @@ import com.azure.storage.common.implementation.connectionstring.StorageConnectionString; import com.azure.storage.common.implementation.connectionstring.StorageEndpoint; import com.azure.storage.common.policy.RequestRetryOptions; +import com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy; import java.net.MalformedURLException; import java.net.URL; @@ -100,11 +103,6 @@ public BlobServiceAsyncClient buildAsyncClient() { boolean anonymousAccess = false; - if (Objects.isNull(storageSharedKeyCredential) && Objects.isNull(tokenCredential) - && Objects.isNull(azureSasCredential) && Objects.isNull(sasToken)) { - anonymousAccess = true; - } - if (Objects.nonNull(customerProvidedKey) && Objects.nonNull(encryptionScope)) { throw logger.logExceptionAsError(new IllegalArgumentException("Customer provided key and encryption " + "scope cannot both be set")); @@ -116,6 +114,23 @@ public BlobServiceAsyncClient buildAsyncClient() { endpoint, retryOptions, logOptions, clientOptions, httpClient, perCallPolicies, perRetryPolicies, configuration, logger); + boolean foundCredential = false; + for (int i = 0; i < pipeline.getPolicyCount(); i++) { + if (pipeline.getPolicy(i) instanceof StorageSharedKeyCredentialPolicy) { + foundCredential = true; + break; + } + if (pipeline.getPolicy(i) instanceof BearerTokenAuthenticationPolicy) { + foundCredential = true; + break; + } + if (pipeline.getPolicy(i) instanceof AzureSasCredentialPolicy) { + foundCredential = true; + break; + } + } + anonymousAccess = !foundCredential; + return new BlobServiceAsyncClient(pipeline, endpoint, serviceVersion, accountName, customerProvidedKey, encryptionScope, blobContainerEncryptionScope, anonymousAccess); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java index 0f5b9bea4d58c..cecf00942c8f2 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/AppendBlobsImpl.java @@ -24,10 +24,10 @@ import com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockResponse; import com.azure.storage.blob.implementation.models.AppendBlobsCreateResponse; import com.azure.storage.blob.implementation.models.AppendBlobsSealResponse; -import com.azure.storage.blob.implementation.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.implementation.models.EncryptionScope; import com.azure.storage.blob.implementation.models.StorageErrorException; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.CpkInfo; import com.azure.storage.blob.models.EncryptionAlgorithmType; import java.net.URL; @@ -162,6 +162,7 @@ Mono appendBlockFromUrl( @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, @HeaderParam("Accept") String accept, Context context); @@ -497,6 +498,8 @@ public Mono appendBlockWithResponseAsync( * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when storage analytics logging is enabled. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. * @param cpkInfo Parameter group. * @param encryptionScope Parameter group. * @param context The context to associate with this operation. @@ -529,6 +532,7 @@ public Mono appendBlockFromUrlWithRespons String sourceIfMatch, String sourceIfNoneMatch, String requestId, + String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScope, Context context) { @@ -595,6 +599,7 @@ public Mono appendBlockFromUrlWithRespons sourceIfNoneMatch, this.client.getVersion(), requestId, + copySourceAuthorization, accept, context); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java index 23133e3b561ce..8aa992bf243b6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlobsImpl.java @@ -28,7 +28,6 @@ import com.azure.core.util.DateTimeRfc1123; import com.azure.storage.blob.implementation.models.BlobDeleteType; import com.azure.storage.blob.implementation.models.BlobExpiryOptions; -import com.azure.storage.blob.implementation.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.implementation.models.BlobTags; import com.azure.storage.blob.implementation.models.BlobsAbortCopyFromURLResponse; import com.azure.storage.blob.implementation.models.BlobsAcquireLeaseResponse; @@ -62,6 +61,7 @@ import com.azure.storage.blob.implementation.models.StorageErrorException; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.CpkInfo; import com.azure.storage.blob.models.DeleteSnapshotsOptionType; import com.azure.storage.blob.models.EncryptionAlgorithmType; @@ -302,10 +302,12 @@ Mono setHttpHeaders( @Put("/{containerName}/{blob}") @ExpectedResponses({200}) - @UnexpectedResponseExceptionType(StorageErrorException.class) + @UnexpectedResponseExceptionType(com.azure.storage.blob.models.BlobStorageException.class) Mono setImmutabilityPolicy( @HostParam("url") String url, @QueryParam("comp") String comp, + @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @@ -317,10 +319,12 @@ Mono setImmutabilityPolicy( @Delete("/{containerName}/{blob}") @ExpectedResponses({200}) - @UnexpectedResponseExceptionType(StorageErrorException.class) + @UnexpectedResponseExceptionType(com.azure.storage.blob.models.BlobStorageException.class) Mono deleteImmutabilityPolicy( @HostParam("url") String url, @QueryParam("comp") String comp, + @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @@ -329,10 +333,12 @@ Mono deleteImmutabilityPolicy( @Put("/{containerName}/{blob}") @ExpectedResponses({200}) - @UnexpectedResponseExceptionType(StorageErrorException.class) + @UnexpectedResponseExceptionType(com.azure.storage.blob.models.BlobStorageException.class) Mono setLegalHold( @HostParam("url") String url, @QueryParam("comp") String comp, + @PathParam("containerName") String containerName, + @PathParam("blob") String blob, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @@ -561,6 +567,7 @@ Mono copyFromURL( @HeaderParam("x-ms-immutability-policy-until-date") DateTimeRfc1123 immutabilityPolicyExpiry, @HeaderParam("x-ms-immutability-policy-mode") BlobImmutabilityPolicyMode immutabilityPolicyMode, @HeaderParam("x-ms-legal-hold") Boolean legalHold, + @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, @HeaderParam("Accept") String accept, Context context); @@ -1395,6 +1402,8 @@ public Mono setHttpHeadersWithResponseAsync( /** * The Set Immutability Policy operation sets the immutability policy on the blob. * + * @param containerName The container name. + * @param blob The blob name. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting * Timeouts for Blob Service Operations.</a>. @@ -1412,6 +1421,8 @@ public Mono setHttpHeadersWithResponseAsync( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono setImmutabilityPolicyWithResponseAsync( + String containerName, + String blob, Integer timeout, String requestId, OffsetDateTime ifUnmodifiedSince, @@ -1427,6 +1438,8 @@ public Mono setImmutabilityPolicyWithRespons return service.setImmutabilityPolicy( this.client.getUrl(), comp, + containerName, + blob, timeout, this.client.getVersion(), requestId, @@ -1440,6 +1453,8 @@ public Mono setImmutabilityPolicyWithRespons /** * The Delete Immutability Policy operation deletes the immutability policy on the blob. * + * @param containerName The container name. + * @param blob The blob name. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting * Timeouts for Blob Service Operations.</a>. @@ -1453,16 +1468,26 @@ public Mono setImmutabilityPolicyWithRespons */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono deleteImmutabilityPolicyWithResponseAsync( - Integer timeout, String requestId, Context context) { + String containerName, String blob, Integer timeout, String requestId, Context context) { final String comp = "immutabilityPolicies"; final String accept = "application/xml"; return service.deleteImmutabilityPolicy( - this.client.getUrl(), comp, timeout, this.client.getVersion(), requestId, accept, context); + this.client.getUrl(), + comp, + containerName, + blob, + timeout, + this.client.getVersion(), + requestId, + accept, + context); } /** * The Set Legal Hold operation sets a legal hold on the blob. * + * @param containerName The container name. + * @param blob The blob name. * @param legalHold Specified if a legal hold should be set on the blob. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting @@ -1477,11 +1502,20 @@ public Mono deleteImmutabilityPolicyWithR */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono setLegalHoldWithResponseAsync( - boolean legalHold, Integer timeout, String requestId, Context context) { + String containerName, String blob, boolean legalHold, Integer timeout, String requestId, Context context) { final String comp = "legalhold"; final String accept = "application/xml"; return service.setLegalHold( - this.client.getUrl(), comp, timeout, this.client.getVersion(), requestId, legalHold, accept, context); + this.client.getUrl(), + comp, + containerName, + blob, + timeout, + this.client.getVersion(), + requestId, + legalHold, + accept, + context); } /** @@ -2167,6 +2201,8 @@ public Mono startCopyFromURLWithResponseAsync( * @param immutabilityPolicyExpiry Specifies the date time when the blobs immutability policy is set to expire. * @param immutabilityPolicyMode Specifies the immutability policy mode to set on the blob. * @param legalHold Specified if a legal hold should be set on the blob. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws StorageErrorException thrown if the request is rejected by server. @@ -2197,6 +2233,7 @@ public Mono copyFromURLWithResponseAsync( OffsetDateTime immutabilityPolicyExpiry, BlobImmutabilityPolicyMode immutabilityPolicyMode, Boolean legalHold, + String copySourceAuthorization, Context context) { final String xMsRequiresSync = "true"; final String accept = "application/xml"; @@ -2237,6 +2274,7 @@ public Mono copyFromURLWithResponseAsync( immutabilityPolicyExpiryConverted, immutabilityPolicyMode, legalHold, + copySourceAuthorization, accept, context); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java index 9770b1489f9f9..87bb9c108ebad 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/BlockBlobsImpl.java @@ -21,7 +21,6 @@ import com.azure.core.util.Base64Util; import com.azure.core.util.Context; import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.implementation.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.implementation.models.BlockBlobsCommitBlockListResponse; import com.azure.storage.blob.implementation.models.BlockBlobsGetBlockListResponse; import com.azure.storage.blob.implementation.models.BlockBlobsPutBlobFromUrlResponse; @@ -32,6 +31,7 @@ import com.azure.storage.blob.implementation.models.StorageErrorException; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.BlockListType; import com.azure.storage.blob.models.BlockLookupList; import com.azure.storage.blob.models.CpkInfo; @@ -148,6 +148,7 @@ Mono putBlobFromUrl( @HeaderParam("x-ms-tags") String blobTagsString, @HeaderParam("x-ms-copy-source") URL copySource, @HeaderParam("x-ms-copy-source-blob-properties") Boolean copySourceBlobProperties, + @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, @HeaderParam("Accept") String accept, Context context); @@ -201,6 +202,7 @@ Mono stageBlockFromURL( @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, @HeaderParam("Accept") String accept, Context context); @@ -473,6 +475,8 @@ public Mono uploadWithResponseAsync( * @param blobTagsString Optional. Used to set blob tags in various blob operations. * @param copySourceBlobProperties Optional, default is true. Indicates if properties from the source blob should be * copied. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. * @param blobHttpHeaders Parameter group. * @param cpkInfo Parameter group. * @param encryptionScope Parameter group. @@ -507,6 +511,7 @@ public Mono putBlobFromUrlWithResponseAsync( byte[] sourceContentMD5, String blobTagsString, Boolean copySourceBlobProperties, + String copySourceAuthorization, BlobHttpHeaders blobHttpHeaders, CpkInfo cpkInfo, EncryptionScope encryptionScope, @@ -611,6 +616,7 @@ public Mono putBlobFromUrlWithResponseAsync( blobTagsString, copySource, copySourceBlobProperties, + copySourceAuthorization, accept, context); } @@ -729,6 +735,8 @@ public Mono stageBlockWithResponseAsync( * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when storage analytics logging is enabled. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. * @param cpkInfo Parameter group. * @param encryptionScope Parameter group. * @param context The context to associate with this operation. @@ -754,6 +762,7 @@ public Mono stageBlockFromURLWithResponseAs String sourceIfMatch, String sourceIfNoneMatch, String requestId, + String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScope, Context context) { @@ -808,6 +817,7 @@ public Mono stageBlockFromURLWithResponseAs sourceIfNoneMatch, this.client.getVersion(), requestId, + copySourceAuthorization, accept, context); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java index 88dd509959c14..89720d3a2ffc6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/PageBlobsImpl.java @@ -21,7 +21,6 @@ import com.azure.core.util.Base64Util; import com.azure.core.util.Context; import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.blob.implementation.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.implementation.models.EncryptionScope; import com.azure.storage.blob.implementation.models.PageBlobsClearPagesResponse; import com.azure.storage.blob.implementation.models.PageBlobsCopyIncrementalResponse; @@ -35,6 +34,7 @@ import com.azure.storage.blob.implementation.models.PremiumPageBlobAccessTier; import com.azure.storage.blob.implementation.models.StorageErrorException; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.CpkInfo; import com.azure.storage.blob.models.EncryptionAlgorithmType; import com.azure.storage.blob.models.SequenceNumberActionType; @@ -208,6 +208,7 @@ Mono uploadPagesFromURL( @HeaderParam("x-ms-source-if-none-match") String sourceIfNoneMatch, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-copy-source-authorization") String copySourceAuthorization, @HeaderParam("Accept") String accept, Context context); @@ -757,6 +758,8 @@ public Mono clearPagesWithResponseAsync( * @param sourceIfNoneMatch Specify an ETag value to operate only on blobs without a matching value. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when storage analytics logging is enabled. + * @param copySourceAuthorization Only Bearer type is supported. Credentials should be a valid OAuth access token to + * copy source. * @param cpkInfo Parameter group. * @param encryptionScope Parameter group. * @param context The context to associate with this operation. @@ -790,6 +793,7 @@ public Mono uploadPagesFromURLWithResponseA String sourceIfMatch, String sourceIfNoneMatch, String requestId, + String copySourceAuthorization, CpkInfo cpkInfo, EncryptionScope encryptionScope, Context context) { @@ -858,6 +862,7 @@ public Mono uploadPagesFromURLWithResponseA sourceIfNoneMatch, this.client.getVersion(), requestId, + copySourceAuthorization, accept, context); } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java index 31dc9df2689e9..887b18437081c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowConfiguration.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; -/** arrow configuration. */ +/** Groups the settings used for formatting the response if the response should be Arrow formatted. */ @JacksonXmlRootElement(localName = "ArrowConfiguration") @Fluent public final class ArrowConfiguration { diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java index d64199574ed83..eebe8075c040c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/ArrowField.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -/** field of an arrow schema. */ +/** Groups settings regarding specific field of an arrow schema. */ @JacksonXmlRootElement(localName = "Field") @Fluent public final class ArrowField { diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java index 3aeb32ebad746..223e34a14e651 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemInternal.java @@ -67,6 +67,12 @@ public final class BlobItemInternal { @JsonProperty(value = "OrMetadata") private Map objectReplicationMetadata; + /* + * The HasVersionsOnly property. + */ + @JsonProperty(value = "HasVersionsOnly") + private Boolean hasVersionsOnly; + /* * The IsPrefix property. */ @@ -253,6 +259,26 @@ public BlobItemInternal setObjectReplicationMetadata(Map objectR return this; } + /** + * Get the hasVersionsOnly property: The HasVersionsOnly property. + * + * @return the hasVersionsOnly value. + */ + public Boolean isHasVersionsOnly() { + return this.hasVersionsOnly; + } + + /** + * Set the hasVersionsOnly property: The HasVersionsOnly property. + * + * @param hasVersionsOnly the hasVersionsOnly value to set. + * @return the BlobItemInternal object itself. + */ + public BlobItemInternal setHasVersionsOnly(Boolean hasVersionsOnly) { + this.hasVersionsOnly = hasVersionsOnly; + return this; + } + /** * Get the isPrefix property: The IsPrefix property. * diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java index 446e4a682d1a3..443916a33dc4d 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobItemPropertiesInternal.java @@ -9,6 +9,7 @@ import com.azure.core.util.DateTimeRfc1123; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.ArchiveStatus; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.BlobType; import com.azure.storage.blob.models.CopyStatusType; import com.azure.storage.blob.models.LeaseDurationType; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java index 671d3c8a9e5af..b86ca93fb0238 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsGetPropertiesHeaders.java @@ -8,6 +8,7 @@ import com.azure.core.annotation.HeaderCollection; import com.azure.core.util.CoreUtils; import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.BlobType; import com.azure.storage.blob.models.CopyStatusType; import com.azure.storage.blob.models.LeaseDurationType; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java index 74eb4099d88f8..2b7553f451265 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsSetImmutabilityPolicyHeaders.java @@ -6,6 +6,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java index 37da273fa7c3c..a0b4209499a0c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/DelimitedTextConfiguration.java @@ -8,42 +8,42 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -/** delimited text configuration. */ +/** Groups the settings used for interpreting the blob data if the blob is delimited text formatted. */ @JacksonXmlRootElement(localName = "DelimitedTextConfiguration") @Fluent public final class DelimitedTextConfiguration { /* - * column separator + * The string used to separate columns. */ - @JsonProperty(value = "ColumnSeparator", required = true) + @JsonProperty(value = "ColumnSeparator") private String columnSeparator; /* - * field quote + * The string used to quote a specific field. */ - @JsonProperty(value = "FieldQuote", required = true) + @JsonProperty(value = "FieldQuote") private String fieldQuote; /* - * record separator + * The string used to separate records. */ - @JsonProperty(value = "RecordSeparator", required = true) + @JsonProperty(value = "RecordSeparator") private String recordSeparator; /* - * escape char + * The string used as an escape character. */ - @JsonProperty(value = "EscapeChar", required = true) + @JsonProperty(value = "EscapeChar") private String escapeChar; /* - * has headers + * Represents whether the data has headers. */ - @JsonProperty(value = "HasHeaders", required = true) - private boolean headersPresent; + @JsonProperty(value = "HasHeaders") + private Boolean headersPresent; /** - * Get the columnSeparator property: column separator. + * Get the columnSeparator property: The string used to separate columns. * * @return the columnSeparator value. */ @@ -52,7 +52,7 @@ public String getColumnSeparator() { } /** - * Set the columnSeparator property: column separator. + * Set the columnSeparator property: The string used to separate columns. * * @param columnSeparator the columnSeparator value to set. * @return the DelimitedTextConfiguration object itself. @@ -63,7 +63,7 @@ public DelimitedTextConfiguration setColumnSeparator(String columnSeparator) { } /** - * Get the fieldQuote property: field quote. + * Get the fieldQuote property: The string used to quote a specific field. * * @return the fieldQuote value. */ @@ -72,7 +72,7 @@ public String getFieldQuote() { } /** - * Set the fieldQuote property: field quote. + * Set the fieldQuote property: The string used to quote a specific field. * * @param fieldQuote the fieldQuote value to set. * @return the DelimitedTextConfiguration object itself. @@ -83,7 +83,7 @@ public DelimitedTextConfiguration setFieldQuote(String fieldQuote) { } /** - * Get the recordSeparator property: record separator. + * Get the recordSeparator property: The string used to separate records. * * @return the recordSeparator value. */ @@ -92,7 +92,7 @@ public String getRecordSeparator() { } /** - * Set the recordSeparator property: record separator. + * Set the recordSeparator property: The string used to separate records. * * @param recordSeparator the recordSeparator value to set. * @return the DelimitedTextConfiguration object itself. @@ -103,7 +103,7 @@ public DelimitedTextConfiguration setRecordSeparator(String recordSeparator) { } /** - * Get the escapeChar property: escape char. + * Get the escapeChar property: The string used as an escape character. * * @return the escapeChar value. */ @@ -112,7 +112,7 @@ public String getEscapeChar() { } /** - * Set the escapeChar property: escape char. + * Set the escapeChar property: The string used as an escape character. * * @param escapeChar the escapeChar value to set. * @return the DelimitedTextConfiguration object itself. @@ -123,21 +123,21 @@ public DelimitedTextConfiguration setEscapeChar(String escapeChar) { } /** - * Get the headersPresent property: has headers. + * Get the headersPresent property: Represents whether the data has headers. * * @return the headersPresent value. */ - public boolean isHeadersPresent() { + public Boolean isHeadersPresent() { return this.headersPresent; } /** - * Set the headersPresent property: has headers. + * Set the headersPresent property: Represents whether the data has headers. * * @param headersPresent the headersPresent value to set. * @return the DelimitedTextConfiguration object itself. */ - public DelimitedTextConfiguration setHeadersPresent(boolean headersPresent) { + public DelimitedTextConfiguration setHeadersPresent(Boolean headersPresent) { this.headersPresent = headersPresent; return this; } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java index 9bf067a122de4..63e827253c19c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/JsonTextConfiguration.java @@ -13,13 +13,13 @@ @Fluent public final class JsonTextConfiguration { /* - * record separator + * The string used to separate records. */ - @JsonProperty(value = "RecordSeparator", required = true) + @JsonProperty(value = "RecordSeparator") private String recordSeparator; /** - * Get the recordSeparator property: record separator. + * Get the recordSeparator property: The string used to separate records. * * @return the recordSeparator value. */ @@ -28,7 +28,7 @@ public String getRecordSeparator() { } /** - * Set the recordSeparator property: record separator. + * Set the recordSeparator property: The string used to separate records. * * @param recordSeparator the recordSeparator value to set. * @return the JsonTextConfiguration object itself. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java index 5318374672fd6..76008b0d81c32 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryFormat.java @@ -19,7 +19,8 @@ public final class QueryFormat { private QueryFormatType type; /* - * delimited text configuration + * Groups the settings used for interpreting the blob data if the blob is + * delimited text formatted. */ @JsonProperty(value = "DelimitedTextConfiguration") private DelimitedTextConfiguration delimitedTextConfiguration; @@ -31,7 +32,8 @@ public final class QueryFormat { private JsonTextConfiguration jsonTextConfiguration; /* - * arrow configuration + * Groups the settings used for formatting the response if the response + * should be Arrow formatted. */ @JsonProperty(value = "ArrowConfiguration") private ArrowConfiguration arrowConfiguration; @@ -63,7 +65,8 @@ public QueryFormat setType(QueryFormatType type) { } /** - * Get the delimitedTextConfiguration property: delimited text configuration. + * Get the delimitedTextConfiguration property: Groups the settings used for interpreting the blob data if the blob + * is delimited text formatted. * * @return the delimitedTextConfiguration value. */ @@ -72,7 +75,8 @@ public DelimitedTextConfiguration getDelimitedTextConfiguration() { } /** - * Set the delimitedTextConfiguration property: delimited text configuration. + * Set the delimitedTextConfiguration property: Groups the settings used for interpreting the blob data if the blob + * is delimited text formatted. * * @param delimitedTextConfiguration the delimitedTextConfiguration value to set. * @return the QueryFormat object itself. @@ -103,7 +107,8 @@ public QueryFormat setJsonTextConfiguration(JsonTextConfiguration jsonTextConfig } /** - * Get the arrowConfiguration property: arrow configuration. + * Get the arrowConfiguration property: Groups the settings used for formatting the response if the response should + * be Arrow formatted. * * @return the arrowConfiguration value. */ @@ -112,7 +117,8 @@ public ArrowConfiguration getArrowConfiguration() { } /** - * Set the arrowConfiguration property: arrow configuration. + * Set the arrowConfiguration property: Groups the settings used for formatting the response if the response should + * be Arrow formatted. * * @param arrowConfiguration the arrowConfiguration value to set. * @return the QueryFormat object itself. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java index 27f7c77c817c8..cdb99cfa0107c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/QueryRequest.java @@ -8,18 +8,19 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -/** the quick query body. */ +/** Groups the set of query request settings. */ @JacksonXmlRootElement(localName = "QueryRequest") @Fluent public final class QueryRequest { /* - * the query type + * Required. The type of the provided query expression. */ @JsonProperty(value = "QueryType", required = true) private String queryType; /* - * a query statement + * The query expression in SQL. The maximum size of the query expression is + * 256KiB. */ @JsonProperty(value = "Expression", required = true) private String expression; @@ -42,7 +43,7 @@ public QueryRequest() { } /** - * Get the queryType property: the query type. + * Get the queryType property: Required. The type of the provided query expression. * * @return the queryType value. */ @@ -51,7 +52,7 @@ public String getQueryType() { } /** - * Set the queryType property: the query type. + * Set the queryType property: Required. The type of the provided query expression. * * @param queryType the queryType value to set. * @return the QueryRequest object itself. @@ -62,7 +63,7 @@ public QueryRequest setQueryType(String queryType) { } /** - * Get the expression property: a query statement. + * Get the expression property: The query expression in SQL. The maximum size of the query expression is 256KiB. * * @return the expression value. */ @@ -71,7 +72,7 @@ public String getExpression() { } /** - * Set the expression property: a query statement. + * Set the expression property: The query expression in SQL. The maximum size of the query expression is 256KiB. * * @param expression the expression value to set. * @return the QueryRequest object itself. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java index 7d1e0f31de4b7..22c6f70adbf5a 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/ModelHelper.java @@ -18,6 +18,8 @@ import com.azure.storage.blob.implementation.models.FilterBlobItem; import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; import com.azure.storage.blob.models.BlobDownloadHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.models.BlobItem; import com.azure.storage.blob.models.BlobItemProperties; import com.azure.storage.blob.models.BlobLeaseRequestConditions; @@ -239,6 +241,13 @@ public static BlobDownloadHeaders populateBlobDownloadHeaders( headers.setObjectReplicationSourcePolicies(objectReplicationSourcePolicies); headers.setSealed(internalHeaders.isXMsBlobSealed()); headers.setLastAccessedTime(internalHeaders.getXMsLastAccessTime()); + headers.setCurrentVersion(internalHeaders.isXMsIsCurrentVersion()); + + headers.setImmutabilityPolicy(new BlobImmutabilityPolicy() + .setPolicyMode(internalHeaders.getXMsImmutabilityPolicyMode() == null ? null + : BlobImmutabilityPolicyMode.fromString(internalHeaders.getXMsImmutabilityPolicyMode())) + .setExpiryTime(internalHeaders.getXMsImmutabilityPolicyUntilDate())); + headers.setHasLegalHold(internalHeaders.isXMsLegalHold()); return headers; } @@ -329,6 +338,11 @@ public static BlobItemProperties populateBlobItemProperties(BlobItemPropertiesIn blobItemProperties.setRehydratePriority(blobItemPropertiesInternal.getRehydratePriority()); blobItemProperties.setSealed(blobItemPropertiesInternal.isSealed()); blobItemProperties.setLastAccessedTime(blobItemPropertiesInternal.getLastAccessedOn()); + blobItemProperties.setExpiryTime(blobItemPropertiesInternal.getExpiresOn()); + blobItemProperties.setImmutabilityPolicy(new BlobImmutabilityPolicy() + .setExpiryTime(blobItemPropertiesInternal.getImmutabilityPolicyExpiresOn()) + .setPolicyMode(blobItemPropertiesInternal.getImmutabilityPolicyMode())); + blobItemProperties.setHasLegalHold(blobItemPropertiesInternal.isLegalHold()); return blobItemProperties; } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java index 8ee9941b2f2d8..45577d0158edb 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerItemProperties.java @@ -364,7 +364,7 @@ public Boolean isImmutableStorageWithVersioningEnabled() { * @param isImmutableStorageWithVersioningEnabled the isImmutableStorageWithVersioningEnabled value to set. * @return the BlobContainerItemProperties object itself. */ - public BlobContainerItemProperties setIsImmutableStorageWithVersioningEnabled( + public BlobContainerItemProperties setImmutableStorageWithVersioningEnabled( Boolean isImmutableStorageWithVersioningEnabled) { this.isImmutableStorageWithVersioningEnabled = isImmutableStorageWithVersioningEnabled; return this; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java index d67cbb799b59d..dc48dd654ca47 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobContainerProperties.java @@ -25,6 +25,7 @@ public final class BlobContainerProperties { private final boolean hasLegalHold; private final String defaultEncryptionScope; private final Boolean encryptionScopeOverridePrevented; + private final Boolean isImmutableStorageWithVersioningEnabled; /** * Constructs a {@link BlobContainerProperties}. @@ -67,6 +68,33 @@ public BlobContainerProperties(final Map metadata, final String final LeaseStatusType leaseStatus, final PublicAccessType blobPublicAccess, final boolean hasImmutabilityPolicy, final boolean hasLegalHold, final String defaultEncryptionScope, final Boolean encryptionScopeOverridePrevented) { + this(metadata, eTag, lastModified, leaseDuration, leaseState, leaseStatus, blobPublicAccess, + hasImmutabilityPolicy, hasLegalHold, defaultEncryptionScope, encryptionScopeOverridePrevented, + null); + } + + /** + * Constructs a {@link BlobContainerProperties}. + * + * @param metadata Metadata associated with the container. + * @param eTag ETag of the container. + * @param lastModified Datetime when the container was last modified. + * @param leaseDuration Type of the lease on the container. + * @param leaseState State of the lease on the container. + * @param leaseStatus Status of the lease on the container. + * @param blobPublicAccess Public access status for the container. + * @param hasImmutabilityPolicy Flag indicating if the container has an immutability policy set on it. + * @param hasLegalHold Flag indicating if the container has a legal hold. + * @param defaultEncryptionScope The container's default encryption scope to encrypt blobs with. + * @param encryptionScopeOverridePrevented Whether or not a container's default encryption scope can be overriden + * @param isImmutableStorageWithVersioningEnabled Whether or not immutable storage with versioning is enabled on + * this container. + */ + public BlobContainerProperties(final Map metadata, final String eTag, + final OffsetDateTime lastModified, final LeaseDurationType leaseDuration, final LeaseStateType leaseState, + final LeaseStatusType leaseStatus, final PublicAccessType blobPublicAccess, final boolean hasImmutabilityPolicy, + final boolean hasLegalHold, final String defaultEncryptionScope, + final Boolean encryptionScopeOverridePrevented, final Boolean isImmutableStorageWithVersioningEnabled) { this.metadata = metadata; this.eTag = eTag; this.lastModified = lastModified; @@ -78,6 +106,7 @@ public BlobContainerProperties(final Map metadata, final String this.hasLegalHold = hasLegalHold; this.defaultEncryptionScope = defaultEncryptionScope; this.encryptionScopeOverridePrevented = encryptionScopeOverridePrevented; + this.isImmutableStorageWithVersioningEnabled = isImmutableStorageWithVersioningEnabled; } /** @@ -156,4 +185,11 @@ public String getDefaultEncryptionScope() { public Boolean isEncryptionScopeOverridePrevented() { return encryptionScopeOverridePrevented; } + + /** + * @return Whether or not immutable storage with versioning is enabled on this container. + */ + public Boolean isImmutableStorageWithVersioningEnabled() { + return isImmutableStorageWithVersioningEnabled; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java index 7f8fa4c22d812..c088ba179ffd6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java @@ -332,6 +332,23 @@ public final class BlobDownloadHeaders { @JsonProperty(value = "LastAccessTime") private OffsetDateTime lastAccessedTime; + /* + * The x-ms-is-current-version property. + */ + @JsonProperty(value = "x-ms-is-current-version") + private Boolean currentVersion; + + /* + * The x-ms-immutability-policy-mode and x-ms-immutability-policy-until-date property. + */ + private BlobImmutabilityPolicy immutabilityPolicy; + + /* + * The x-ms-legal-hold property. + */ + @JsonProperty(value = "x-ms-legal-hold") + private Boolean hasLegalHold; + /** * Get the lastModified property: Returns the date and time the container * was last modified. Any operation that modifies the blob, including an @@ -1304,4 +1321,66 @@ public BlobDownloadHeaders setLastAccessedTime(OffsetDateTime lastAccessedTime) this.lastAccessedTime = lastAccessedTime; return this; } + + /** + * Get the currentVersion property: The x-ms-is-current-version property. + * + * @return the currentVersion value. + */ + public Boolean isCurrentVersion() { + return this.currentVersion; + } + + /** + * Set the currentVersion property: The x-ms-is-current-version property. + * + * @param currentVersion the currentVersion value to set. + * @return the BlobDownloadHeaders object itself. + */ + public BlobDownloadHeaders setCurrentVersion(Boolean currentVersion) { + this.currentVersion = currentVersion; + return this; + } + + /** + * Get the immutabilityPolicy property: The x-ms-immutability-policy-mode and x-ms-immutability-policy-until-date + * property. + * + * @return the immutabilityPolicy value. + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return this.immutabilityPolicy; + } + + /** + * Set the immutabilityPolicy property: x-ms-immutability-policy-mode and x-ms-immutability-policy-until-date + * property. + * + * @param immutabilityPolicy the immutabilityPolicy value to set. + * @return the BlobDownloadHeaders object itself. + */ + public BlobDownloadHeaders setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * Get the hasLegalHold property: The x-ms-legal-hold property. + * + * @return the hasLegalHold value. + */ + public Boolean hasLegalHold() { + return this.hasLegalHold; + } + + /** + * Set the hasLegalHold property: The x-ms-legal-hold property. + * + * @param hasLegalHold the xMsLegalHold value to set. + * @return the BlobDownloadHeaders object itself. + */ + public BlobDownloadHeaders setHasLegalHold(Boolean hasLegalHold) { + this.hasLegalHold = hasLegalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java new file mode 100644 index 0000000000000..c6308f8efb385 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicy.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob.models; + +import java.time.OffsetDateTime; + +/** + * Optional parameters for setting the immutability policy of a blob, blob snapshot or blob version. + */ +public class BlobImmutabilityPolicy { + + private OffsetDateTime expiryTime; + private BlobImmutabilityPolicyMode policyMode; + + /** + * @return The time when the immutability policy expires. + */ + public OffsetDateTime getExpiryTime() { + return expiryTime; + } + + /** + * @param expiryTime The time when the immutability policy expires. + * @return The updated BlobImmutabilityPolicy + */ + public BlobImmutabilityPolicy setExpiryTime(OffsetDateTime expiryTime) { + this.expiryTime = expiryTime; + return this; + } + + /** + * @return The immutability policy mode. + */ + public BlobImmutabilityPolicyMode getPolicyMode() { + return policyMode; + } + + /** + * @param policyMode The immutability policy mode. + * @return The updated BlobImmutabilityPolicy + */ + public BlobImmutabilityPolicy setPolicyMode(BlobImmutabilityPolicyMode policyMode) { + this.policyMode = policyMode; + return this; + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobImmutabilityPolicyMode.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java similarity index 93% rename from sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobImmutabilityPolicyMode.java rename to sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java index 4c483833f7ac0..c43ac19042d5e 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobImmutabilityPolicyMode.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobImmutabilityPolicyMode.java @@ -2,21 +2,21 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. -package com.azure.storage.blob.implementation.models; +package com.azure.storage.blob.models; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; /** Defines values for BlobImmutabilityPolicyMode. */ public enum BlobImmutabilityPolicyMode { + /** Enum value Mutable. */ + MUTABLE("Mutable"), + /** Enum value Unlocked. */ UNLOCKED("Unlocked"), /** Enum value Locked. */ - LOCKED("Locked"), - - /** Enum value Mutable. */ - MUTABLE("Mutable"); + LOCKED("Locked"); /** The actual serialized value for a BlobImmutabilityPolicyMode instance. */ private final String value; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java index 233ea037bacfe..29bbe0d8b89ff 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobItemProperties.java @@ -237,6 +237,23 @@ public final class BlobItemProperties { @JsonProperty(value = "LastAccessTime") private OffsetDateTime lastAccessedTime; + /* + * The Expiry-Time property. + */ + @JsonProperty(value = "Expiry-Time") + private OffsetDateTime expiryTime; + + /* + * The ImmutabilityPolicyUntilDate and ImmutabilityPolicyMode property. + */ + private BlobImmutabilityPolicy immutabilityPolicy; + + /* + * The LegalHold property. + */ + @JsonProperty(value = "LegalHold") + private Boolean hasLegalHold; + /** * Get the creationTime property: The creationTime property. * @@ -985,4 +1002,64 @@ public BlobItemProperties setLastAccessedTime(OffsetDateTime lastAccessedTime) { this.lastAccessedTime = lastAccessedTime; return this; } + + /** + * Get the expiryTime property: The Expiry-Time property. + * + * @return the expiryTime value. + */ + public OffsetDateTime getExpiryTime() { + return this.expiryTime; + } + + /** + * Set the expiryTime property: The Expiry-Time property. + * + * @param expiryTime the expiryTime value to set. + * @return the BlobItemProperties object itself. + */ + public BlobItemProperties setExpiryTime(OffsetDateTime expiryTime) { + this.expiryTime = expiryTime; + return this; + } + + /** + * Get the immutabilityPolicy property: The ImmutabilityPolicyUntilDate and ImmutabilityPolicyMode property. + * + * @return the immutabilityPolicy value. + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return this.immutabilityPolicy; + } + + /** + * Set the immutabilityPolicy property: The ImmutabilityPolicyUntilDate and ImmutabilityPolicyMode property. + * + * @param immutabilityPolicy the immutabilityPolicy value to set. + * @return the BlobItemProperties object itself. + */ + public BlobItemProperties setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * Get the hasLegalHold property: The LegalHold property. + * + * @return the hasLegalHold value. + */ + public Boolean hasLegalHold() { + return this.hasLegalHold; + } + + /** + * Set the hasLegalHold property: The LegalHold property. + * + * @param hasLegalHold the v value to set. + * @return the BlobItemProperties object itself. + */ + public BlobItemProperties setHasLegalHold(Boolean hasLegalHold) { + this.hasLegalHold = hasLegalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java new file mode 100644 index 0000000000000..a251795284912 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobLegalHoldResult.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob.models; + +/** + * The blob legal hold result. + */ +public class BlobLegalHoldResult { + + private final boolean hasLegalHold; + + /** + * Creates a new BlobLegalHoldResult + * @param hasLegalHold whether or not a legal hold is enabled on the blob. + */ + public BlobLegalHoldResult(boolean hasLegalHold) { + this.hasLegalHold = hasLegalHold; + } + + /** + * @return whether or not a legal hold is enabled on the blob. + */ + public boolean hasLegalHold() { + return hasLegalHold; + } +} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java index ba7e4ae389990..044dd4ac6e66c 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobListDetails.java @@ -23,6 +23,8 @@ public final class BlobListDetails { private boolean retrieveUncommittedBlobs; private boolean retrieveDeletedBlobs; private boolean retrieveVersions; + private boolean retrieveImmutabilityPolicy; + private boolean retrieveLegalHold; /** * Constructs an unpopulated {@link BlobListDetails}. @@ -172,6 +174,46 @@ public BlobListDetails setRetrieveDeletedBlobs(boolean retrieveDeletedBlobs) { return this; } + /** + * Whether immutability policy for the blob should be returned. + * + * @return a flag indicating if immutability policy for the blob will be returned in the listing + */ + public boolean getRetrieveImmutabilityPolicy() { + return retrieveImmutabilityPolicy; + } + + /** + * Whether immutability policy for the blob should be returned. + * + * @param retrieveImmutabilityPolicy Flag indicating whether immutability policy for the blob should be returned + * @return the updated BlobListDetails object + */ + public BlobListDetails setRetrieveImmutabilityPolicy(boolean retrieveImmutabilityPolicy) { + this.retrieveImmutabilityPolicy = retrieveImmutabilityPolicy; + return this; + } + + /** + * Whether legal hold for the blob should be returned. + * + * @return a flag indicating if legal hold for the blob will be returned in the listing + */ + public boolean getRetrieveLegalHold() { + return retrieveLegalHold; + } + + /** + * Whether legal hold for the blob should be returned. + * + * @param retrieveLegalHold Flag indicating whetherlegal hold for the blob should be returned + * @return the updated BlobListDetails object + */ + public BlobListDetails setRetrieveLegalHold(boolean retrieveLegalHold) { + this.retrieveLegalHold = retrieveLegalHold; + return this; + } + /** * @return a list of the flag set to true */ @@ -198,6 +240,12 @@ public ArrayList toList() { if (this.retrieveVersions) { details.add(ListBlobsIncludeItem.VERSIONS); } + if (this.retrieveImmutabilityPolicy) { + details.add(ListBlobsIncludeItem.IMMUTABILITYPOLICY); + } + if (this.retrieveLegalHold) { + details.add(ListBlobsIncludeItem.LEGALHOLD); + } return details; } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java index ac761eb38760a..cf75ae65dede1 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobProperties.java @@ -58,6 +58,9 @@ public final class BlobProperties { private final Boolean isSealed; private final OffsetDateTime lastAccessedTime; private final OffsetDateTime expiresOn; + private final BlobImmutabilityPolicy immutabilityPolicy; + private final Boolean hasLegalHold; + /** * Constructs a {@link BlobProperties}. * @@ -311,6 +314,80 @@ public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime la final List objectReplicationSourcePolicies, final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn) { + this(creationTime, lastModified, eTag, blobSize, contentType, contentMd5, contentEncoding, contentDisposition, + contentLanguage, cacheControl, blobSequenceNumber, blobType, leaseStatus, leaseState, leaseDuration, + copyId, copyStatus, copySource, copyProgress, copyCompletionTime, copyStatusDescription, isServerEncrypted, + isIncrementalCopy, copyDestinationSnapshot, accessTier, isAccessTierInferred, archiveStatus, + encryptionKeySha256, encryptionScope, accessTierChangeTime, metadata, committedBlockCount, tagCount, + versionId, isCurrentVersion, objectReplicationSourcePolicies, objectReplicationDestinationPolicyId, + rehydratePriority, isSealed, lastAccessedTime, expiresOn, null, false); + } + + /** + * Constructs a {@link BlobProperties}. + * + * @param creationTime Creation time of the blob. + * @param lastModified Datetime when the blob was last modified. + * @param eTag ETag of the blob. + * @param blobSize Size of the blob. + * @param contentType Content type specified for the blob. + * @param contentMd5 Content MD5 specified for the blob. + * @param contentEncoding Content encoding specified for the blob. + * @param contentDisposition Content disposition specified for the blob. + * @param contentLanguage Content language specified for the blob. + * @param cacheControl Cache control specified for the blob. + * @param blobSequenceNumber The current sequence number for a page blob, if the blob is an append or block blob + * pass {@code null}. + * @param blobType Type of the blob. + * @param leaseStatus Status of the lease on the blob. + * @param leaseState State of the lease on the blob. + * @param leaseDuration Type of lease on the blob. + * @param copyId Identifier of the last copy operation performed on the blob. + * @param copyStatus Status of the last copy operation performed on the blob. + * @param copySource Source of the last copy operation performed on the blob. + * @param copyProgress Progress of the last copy operation performed on the blob. + * @param copyCompletionTime Datetime when the last copy operation on the blob completed. + * @param copyStatusDescription Description of the last copy operation on the blob. + * @param isServerEncrypted Flag indicating if the blob's content is encrypted on the server. + * @param isIncrementalCopy Flag indicating if the blob was incrementally copied. + * @param copyDestinationSnapshot Snapshot identifier of the last incremental copy snapshot for the blob. + * @param accessTier Access tier of the blob. + * @param isAccessTierInferred Flag indicating if the access tier of the blob was inferred from properties of the + * blob. + * @param archiveStatus Archive status of the blob. + * @param encryptionKeySha256 SHA256 of the customer provided encryption key used to encrypt the blob on the server. + * @param encryptionScope The name of the encryption scope under which the blob is encrypted. + * @param accessTierChangeTime Datetime when the access tier of the blob last changed. + * @param metadata Metadata associated with the blob. + * @param committedBlockCount Number of blocks committed to an append blob, if the blob is a block or page blob + * pass {@code null}. + * @param versionId The version identifier of the blob. + * @param isCurrentVersion Flag indicating if version identifier points to current version of the blob. + * @param tagCount Number of tags associated with the blob. + * @param objectReplicationSourcePolicies The already parsed object replication policies. + * @param objectReplicationDestinationPolicyId The policy id on the destination blob. + * @param rehydratePriority The rehydrate priority + * @param isSealed Whether or not the blob is sealed. + * @param lastAccessedTime The date and time the blob was read or written to. + * @param expiresOn The time when the blob is going to expire. + * @param immutabilityPolicy the immutability policy of the blob. + * @param hasLegalHold whether or not the blob has a legal hold. + */ + public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime lastModified, final String eTag, + final long blobSize, final String contentType, final byte[] contentMd5, final String contentEncoding, + final String contentDisposition, final String contentLanguage, final String cacheControl, + final Long blobSequenceNumber, final BlobType blobType, final LeaseStatusType leaseStatus, + final LeaseStateType leaseState, final LeaseDurationType leaseDuration, final String copyId, + final CopyStatusType copyStatus, final String copySource, final String copyProgress, + final OffsetDateTime copyCompletionTime, final String copyStatusDescription, final Boolean isServerEncrypted, + final Boolean isIncrementalCopy, final String copyDestinationSnapshot, final AccessTier accessTier, + final Boolean isAccessTierInferred, final ArchiveStatus archiveStatus, final String encryptionKeySha256, + final String encryptionScope, final OffsetDateTime accessTierChangeTime, final Map metadata, + final Integer committedBlockCount, final Long tagCount, final String versionId, final Boolean isCurrentVersion, + final List objectReplicationSourcePolicies, + final String objectReplicationDestinationPolicyId, final RehydratePriority rehydratePriority, + final Boolean isSealed, final OffsetDateTime lastAccessedTime, final OffsetDateTime expiresOn, + BlobImmutabilityPolicy immutabilityPolicy, Boolean hasLegalHold) { this.creationTime = creationTime; this.lastModified = lastModified; this.eTag = eTag; @@ -352,6 +429,8 @@ public BlobProperties(final OffsetDateTime creationTime, final OffsetDateTime la this.isSealed = isSealed; this.lastAccessedTime = lastAccessedTime; this.expiresOn = expiresOn; + this.immutabilityPolicy = immutabilityPolicy; + this.hasLegalHold = hasLegalHold; } /** @@ -655,4 +734,18 @@ public OffsetDateTime getLastAccessedTime() { public OffsetDateTime getExpiresOn() { return expiresOn; } + + /** + * @return the immutability policy. + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * @return whether or not the blob has a legal hold. + */ + public Boolean hasLegalHold() { + return hasLegalHold; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java index ad4397648c4da..c6e027742245b 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ListBlobsIncludeItem.java @@ -34,7 +34,10 @@ public enum ListBlobsIncludeItem { IMMUTABILITYPOLICY("immutabilitypolicy"), /** Enum value legalhold. */ - LEGALHOLD("legalhold"); + LEGALHOLD("legalhold"), + + /** Enum value deletedwithversions. */ + DELETEDWITHVERSIONS("deletedwithversions"); /** The actual serialized value for a ListBlobsIncludeItem instance. */ private final String value; diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java index 27ab7db71b626..8991c7916c1d9 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/AppendBlobCreateOptions.java @@ -5,6 +5,7 @@ import com.azure.core.annotation.Fluent; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import java.util.Map; @@ -18,6 +19,8 @@ public class AppendBlobCreateOptions { private Map metadata; private Map tags; private BlobRequestConditions requestConditions; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * @return {@link BlobHttpHeaders} @@ -82,4 +85,40 @@ public AppendBlobCreateOptions setRequestConditions(BlobRequestConditions reques this.requestConditions = requestConditions; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public AppendBlobCreateOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public AppendBlobCreateOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java index ecf3da6949d01..a025c6bf33e7f 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobBeginCopyOptions.java @@ -5,6 +5,7 @@ import com.azure.core.annotation.Fluent; import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; import com.azure.storage.blob.models.RehydratePriority; @@ -27,6 +28,8 @@ public class BlobBeginCopyOptions { private BlobRequestConditions destinationRequestConditions; private Duration pollInterval; private Boolean sealDestination; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * @param sourceUrl The source URL to copy from. URLs outside of Azure may only be copied to block blobs. @@ -176,4 +179,40 @@ public BlobBeginCopyOptions setSealDestination(Boolean sealDestination) { this.sealDestination = sealDestination; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public BlobBeginCopyOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public BlobBeginCopyOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java index 5e92e2d9d4993..bb96450327a86 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobCopyFromUrlOptions.java @@ -6,6 +6,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.http.RequestConditions; import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.common.implementation.StorageImplUtils; @@ -22,6 +23,8 @@ public class BlobCopyFromUrlOptions { private AccessTier tier; private RequestConditions sourceRequestConditions; private BlobRequestConditions destinationRequestConditions; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs. @@ -118,4 +121,40 @@ public BlobCopyFromUrlOptions setDestinationRequestConditions(BlobRequestConditi this.destinationRequestConditions = destinationRequestConditions; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public BlobCopyFromUrlOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public BlobCopyFromUrlOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java index b4825c1b2a0bb..3943a4230f467 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java @@ -9,6 +9,7 @@ import com.azure.storage.blob.BlobClient; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.ParallelTransferOptions; import com.azure.storage.common.implementation.StorageImplUtils; @@ -35,6 +36,8 @@ public class BlobParallelUploadOptions { private BlobRequestConditions requestConditions; private boolean computeMd5; private Duration timeout; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * Constructs a new {@code BlobParallelUploadOptions}. @@ -274,4 +277,40 @@ public BlobParallelUploadOptions setTimeout(Duration timeout) { this.timeout = timeout; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public BlobParallelUploadOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public BlobParallelUploadOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java index 8f1fa15aa1078..3227f8f6ebae6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobCommitBlockListOptions.java @@ -6,6 +6,7 @@ import com.azure.core.annotation.Fluent; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import java.util.Collections; @@ -23,6 +24,8 @@ public class BlockBlobCommitBlockListOptions { private Map tags; private AccessTier tier; private BlobRequestConditions requestConditions; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * @param base64BlockIds A list of base64 encode {@code String}s that specifies the block IDs to be committed. @@ -117,4 +120,40 @@ public BlockBlobCommitBlockListOptions setRequestConditions(BlobRequestCondition this.requestConditions = requestConditions; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public BlockBlobCommitBlockListOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public BlockBlobCommitBlockListOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java index bf1c9e0a83ae9..d99af65343468 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlockBlobSimpleUploadOptions.java @@ -6,6 +6,7 @@ import com.azure.core.util.CoreUtils; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.common.implementation.StorageImplUtils; import reactor.core.publisher.Flux; @@ -27,6 +28,8 @@ public class BlockBlobSimpleUploadOptions { private AccessTier tier; private byte[] contentMd5; private BlobRequestConditions requestConditions; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled @@ -179,4 +182,40 @@ public BlockBlobSimpleUploadOptions setRequestConditions(BlobRequestConditions r this.requestConditions = requestConditions; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public BlockBlobSimpleUploadOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public BlockBlobSimpleUploadOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java index 89f6e3b4e8014..915b1da1071c9 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/PageBlobCreateOptions.java @@ -4,6 +4,7 @@ package com.azure.storage.blob.options; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRequestConditions; import java.util.Map; @@ -18,6 +19,8 @@ public class PageBlobCreateOptions { private Map metadata; private Map tags; private BlobRequestConditions requestConditions; + private BlobImmutabilityPolicy immutabilityPolicy; + private Boolean legalHold; /** * @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a @@ -116,4 +119,40 @@ public PageBlobCreateOptions setRequestConditions(BlobRequestConditions requestC this.requestConditions = requestConditions; return this; } + + /** + * @return {@link BlobImmutabilityPolicy} + */ + public BlobImmutabilityPolicy getImmutabilityPolicy() { + return immutabilityPolicy; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param immutabilityPolicy {@link BlobImmutabilityPolicy} + * @return The updated options. + */ + public PageBlobCreateOptions setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * @return If a legal hold should be placed on the blob. + */ + public Boolean isLegalHold() { + return legalHold; + } + + /** + * Note that this parameter is only applicable to a blob within a container that has immutable storage with + * versioning enabled. + * @param legalHold Indicates if a legal hold should be placed on the blob. + * @return The updated options. + */ + public PageBlobCreateOptions setLegalHold(Boolean legalHold) { + this.legalHold = legalHold; + return this; + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java index 71387cc63efd3..f939f6458c0ca 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobContainerSasPermission.java @@ -35,6 +35,8 @@ public final class BlobContainerSasPermission { private boolean executePermission; + private boolean immutabilityPolicyPermission; + /** * Initializes an {@code BlobContainerSasPermission} object with all fields set to false. */ @@ -47,7 +49,8 @@ public BlobContainerSasPermission() { * * @param permissionString A {@code String} which represents the {@code BlobContainerSasPermission}. * @return A {@code BlobContainerSasPermission} generated from the given {@code String}. - * @throws IllegalArgumentException If {@code permissionString} contains a character other than r, a, c, w, d, x, l or t. + * @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x, l, t or + * i. */ public static BlobContainerSasPermission parse(String permissionString) { BlobContainerSasPermission permissions = new BlobContainerSasPermission(); @@ -85,6 +88,9 @@ public static BlobContainerSasPermission parse(String permissionString) { case 'e': permissions.executePermission = true; break; + case 'i': + permissions.immutabilityPolicyPermission = true; + break; default: throw new IllegalArgumentException( String.format(Locale.ROOT, Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE, @@ -274,6 +280,24 @@ public BlobContainerSasPermission setExecutePermission(boolean hasExecutePermiss return this; } + /** + * @return the set immutability policy permission status. + */ + public boolean hasImmutabilityPolicyPermission() { + return immutabilityPolicyPermission; + } + + /** + * Sets the set immutability policy permission status. + * + * @param immutabilityPolicyPermission Permission status to set + * @return the updated BlobSasPermission object. + */ + public BlobContainerSasPermission setImmutabilityPolicyPermission(boolean immutabilityPolicyPermission) { + this.immutabilityPolicyPermission = immutabilityPolicyPermission; + return this; + } + /** * Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an * order accepted by the service. @@ -326,6 +350,10 @@ public String toString() { builder.append('e'); } + if (this.immutabilityPolicyPermission) { + builder.append('i'); + } + return builder.toString(); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java index a4b55cd4d914e..7098aff0abb45 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobSasPermission.java @@ -35,6 +35,8 @@ public final class BlobSasPermission { private boolean executePermission; + private boolean immutabilityPolicyPermission; + /** * Initializes a {@code BlobSasPermission} object with all fields set to false. */ @@ -47,8 +49,8 @@ public BlobSasPermission() { * * @param permissionString A {@code String} which represents the {@code BlobSasPermission}. * @return A {@code BlobSasPermission} generated from the given {@code String}. - * @throws IllegalArgumentException If {@code permissionString} contains a character other than r, a, c, w, d, x, l, t, - * m, or e. + * @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x, l, t, + * m, e or i. */ public static BlobSasPermission parse(String permissionString) { BlobSasPermission permissions = new BlobSasPermission(); @@ -86,6 +88,9 @@ public static BlobSasPermission parse(String permissionString) { case 'e': permissions.executePermission = true; break; + case 'i': + permissions.immutabilityPolicyPermission = true; + break; default: throw new IllegalArgumentException( String.format(Locale.ROOT, Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE, @@ -275,6 +280,23 @@ public BlobSasPermission setExecutePermission(boolean hasExecutePermission) { return this; } + /** + * @return the set immutability policy permission status. + */ + public boolean hasImmutabilityPolicyPermission() { + return immutabilityPolicyPermission; + } + + /** + * Sets the set immutability policy permission status. + * + * @param immutabilityPolicyPermission Permission status to set + * @return the updated BlobSasPermission object. + */ + public BlobSasPermission setImmutabilityPolicyPermission(boolean immutabilityPolicyPermission) { + this.immutabilityPolicyPermission = immutabilityPolicyPermission; + return this; + } /** * Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an @@ -329,6 +351,10 @@ public String toString() { builder.append('e'); } + if (this.immutabilityPolicyPermission) { + builder.append('i'); + } + return builder.toString(); } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java index 83a1ba8b4f7f7..da6752f193aae 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java @@ -21,6 +21,7 @@ import com.azure.storage.blob.implementation.models.AppendBlobsAppendBlockHeaders; import com.azure.storage.blob.implementation.models.AppendBlobsCreateHeaders; import com.azure.storage.blob.implementation.models.EncryptionScope; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.options.AppendBlobCreateOptions; import com.azure.storage.blob.models.AppendBlobRequestConditions; import com.azure.storage.blob.models.AppendBlobItem; @@ -194,12 +195,15 @@ Mono> createWithResponse(AppendBlobCreateOptions option BlobRequestConditions requestConditions = options.getRequestConditions(); requestConditions = (requestConditions == null) ? new BlobRequestConditions() : requestConditions; context = context == null ? Context.NONE : context; + BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); return this.azureBlobStorage.getAppendBlobs().createWithResponseAsync(containerName, blobName, 0, null, options.getMetadata(), requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - tagsToString(options.getTags()), null, null, null, options.getHeaders(), getCustomerProvidedKey(), + tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), + options.isLegalHold(), options.getHeaders(), getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { AppendBlobsCreateHeaders hd = rb.getDeserializedHeaders(); @@ -369,7 +373,7 @@ Mono> appendBlockFromUrlWithResponse(String sourceUrl, destRequestConditions.getIfMatch(), destRequestConditions.getIfNoneMatch(), destRequestConditions.getTagsConditions(), sourceRequestConditions.getIfModifiedSince(), sourceRequestConditions.getIfUnmodifiedSince(), sourceRequestConditions.getIfMatch(), - sourceRequestConditions.getIfNoneMatch(), null, getCustomerProvidedKey(), encryptionScope, + sourceRequestConditions.getIfNoneMatch(), null, null, getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { AppendBlobsAppendBlockFromUrlHeaders hd = rb.getDeserializedHeaders(); diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java index 8a358e19ecb90..f92df4953b6ea 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java @@ -30,6 +30,7 @@ import com.azure.storage.blob.implementation.models.BlobTags; import com.azure.storage.blob.implementation.models.BlobsGetAccountInfoHeaders; import com.azure.storage.blob.implementation.models.BlobsGetPropertiesHeaders; +import com.azure.storage.blob.implementation.models.BlobsSetImmutabilityPolicyHeaders; import com.azure.storage.blob.implementation.models.BlobsStartCopyFromURLHeaders; import com.azure.storage.blob.implementation.models.EncryptionScope; import com.azure.storage.blob.implementation.models.QueryRequest; @@ -46,6 +47,9 @@ import com.azure.storage.blob.models.BlobCopyInfo; import com.azure.storage.blob.models.BlobDownloadAsyncResponse; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; +import com.azure.storage.blob.models.BlobLegalHoldResult; import com.azure.storage.blob.models.BlobProperties; import com.azure.storage.blob.models.BlobQueryAsyncResponse; import com.azure.storage.blob.models.BlobRange; @@ -542,13 +546,16 @@ public PollerFlux beginCopy(BlobBeginCopyOptions options) { options.getDestinationRequestConditions() == null ? new BlobRequestConditions() : options.getDestinationRequestConditions(); + final BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); return new PollerFlux<>(interval, (pollingContext) -> { try { return onStart(options.getSourceUrl(), options.getMetadata(), options.getTags(), options.getTier(), options.getRehydratePriority(), options.isSealDestination(), - sourceModifiedCondition, destinationRequestConditions); + sourceModifiedCondition, destinationRequestConditions, immutabilityPolicy, + options.isLegalHold()); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -581,7 +588,8 @@ public PollerFlux beginCopy(BlobBeginCopyOptions options) { private Mono onStart(String sourceUrl, Map metadata, Map tags, AccessTier tier, RehydratePriority priority, Boolean sealBlob, BlobBeginCopySourceRequestConditions sourceModifiedRequestConditions, - BlobRequestConditions destinationRequestConditions) { + BlobRequestConditions destinationRequestConditions, BlobImmutabilityPolicy immutabilityPolicy, + Boolean legalHold) { URL url; try { url = new URL(sourceUrl); @@ -597,7 +605,8 @@ private Mono onStart(String sourceUrl, Map metadat destinationRequestConditions.getIfModifiedSince(), destinationRequestConditions.getIfUnmodifiedSince(), destinationRequestConditions.getIfMatch(), destinationRequestConditions.getIfNoneMatch(), destinationRequestConditions.getTagsConditions(), destinationRequestConditions.getLeaseId(), null, - tagsToString(tags), sealBlob, null, null, null, context)) + tagsToString(tags), sealBlob, immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), + legalHold, context)) .map(response -> { final BlobsStartCopyFromURLHeaders headers = response.getDeserializedHeaders(); @@ -816,6 +825,8 @@ Mono> copyFromUrlWithResponse(BlobCopyFromUrlOptions options, C ? new RequestConditions() : options.getSourceRequestConditions(); BlobRequestConditions destRequestConditions = options.getDestinationRequestConditions() == null ? new BlobRequestConditions() : options.getDestinationRequestConditions(); + BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); URL url; try { @@ -832,7 +843,8 @@ Mono> copyFromUrlWithResponse(BlobCopyFromUrlOptions options, C destRequestConditions.getIfUnmodifiedSince(), destRequestConditions.getIfMatch(), destRequestConditions.getIfNoneMatch(), destRequestConditions.getTagsConditions(), destRequestConditions.getLeaseId(), null, null, - tagsToString(options.getTags()), null, null, null, context) + tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), + options.isLegalHold(), null, context) .map(rb -> new SimpleResponse<>(rb, rb.getDeserializedHeaders().getXMsCopyId())); } @@ -1291,7 +1303,7 @@ private static Response buildBlobPropertiesResponse(BlobDownload hd.getEncryptionKeySha256(), hd.getEncryptionScope(), null, hd.getMetadata(), hd.getBlobCommittedBlockCount(), hd.getTagCount(), hd.getVersionId(), null, hd.getObjectReplicationSourcePolicies(), hd.getObjectReplicationDestinationPolicyId(), null, - hd.isSealed(), hd.getLastAccessedTime(), null); + hd.isSealed(), hd.getLastAccessedTime(), null, hd.getImmutabilityPolicy(), hd.hasLegalHold()); return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), properties); } @@ -1445,7 +1457,9 @@ Mono> getPropertiesWithResponse(BlobRequestConditions r ModelHelper.getObjectReplicationSourcePolicies(hd.getXMsOr()), ModelHelper.getObjectReplicationDestinationPolicyId(hd.getXMsOr()), RehydratePriority.fromString(hd.getXMsRehydratePriority()), hd.isXMsBlobSealed(), - hd.getXMsLastAccessTime(), hd.getXMsExpiryTime()); + hd.getXMsLastAccessTime(), hd.getXMsExpiryTime(), new BlobImmutabilityPolicy() + .setExpiryTime(hd.getXMsImmutabilityPolicyUntilDate()) + .setPolicyMode(hd.getXMsImmutabilityPolicyMode()), hd.isXMsLegalHold()); return new SimpleResponse<>(rb, properties); }); } @@ -2083,4 +2097,174 @@ qr, getCustomerProvidedKey(), context) .read(), ModelHelper.transformQueryHeaders(response.getHeaders()))); } + + /** + * Sets the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * object level immutable policy enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy} + * + * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. + * @return A reactive response containing the immutability policy. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + try { + return setImmutabilityPolicyWithResponse(immutabilityPolicy, null).flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Sets the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions} + * + * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. + * @param requestConditions {@link BlobRequestConditions} + * @return A reactive response containing the immutability policy. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setImmutabilityPolicyWithResponse( + BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions) { + try { + return withContext(context -> setImmutabilityPolicyWithResponse(immutabilityPolicy, requestConditions, + context)); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + Mono> setImmutabilityPolicyWithResponse( + BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions, Context context) { + context = context == null ? Context.NONE : context; + BlobImmutabilityPolicy finalImmutabilityPolicy = immutabilityPolicy == null ? new BlobImmutabilityPolicy() + : immutabilityPolicy; + if (BlobImmutabilityPolicyMode.MUTABLE.equals(finalImmutabilityPolicy.getPolicyMode())) { + throw logger.logExceptionAsError(new IllegalArgumentException( + String.format("immutabilityPolicy.policyMode must be %s or %s", + BlobImmutabilityPolicyMode.LOCKED.toString(), BlobImmutabilityPolicyMode.UNLOCKED.toString()))); + } + + BlobRequestConditions finalRequestConditions = requestConditions == null + ? new BlobRequestConditions() : requestConditions; + // TODO (gapra) : Discuss, should we just expose ifUnmodifiedSince here? + return this.azureBlobStorage.getBlobs().setImmutabilityPolicyWithResponseAsync(containerName, blobName, null, + null, finalRequestConditions.getIfUnmodifiedSince(), finalImmutabilityPolicy.getExpiryTime(), + finalImmutabilityPolicy.getPolicyMode(), + context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) + .map(response -> { + BlobsSetImmutabilityPolicyHeaders headers = response.getDeserializedHeaders(); + BlobImmutabilityPolicy responsePolicy = new BlobImmutabilityPolicy() + .setPolicyMode(headers.getXMsImmutabilityPolicyMode()) + .setExpiryTime(headers.getXMsImmutabilityPolicyUntilDate()); + return new SimpleResponse<>(response, responsePolicy); + }); + } + + /** + * Deletes the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * object level immutable policy enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicy} + * + * @return A reactive response signalling completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteImmutabilityPolicy() { + try { + return deleteImmutabilityPolicyWithResponse().flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Deletes the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicyWithResponse} + * + * @return A reactive response signalling completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteImmutabilityPolicyWithResponse() { + try { + return withContext(this::deleteImmutabilityPolicyWithResponse); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + Mono> deleteImmutabilityPolicyWithResponse(Context context) { + context = context == null ? Context.NONE : context; + return this.azureBlobStorage.getBlobs().deleteImmutabilityPolicyWithResponseAsync(containerName, blobName, + null, null, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) + .map(response -> new SimpleResponse<>(response, null)); + } + + /** + * Sets a legal hold on the blob. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * object level immutable policy enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHold#boolean} + * + * @param legalHold Whether or not you want a legal hold on the blob. + * @return A reactive response containing the legal hold result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setLegalHold(boolean legalHold) { + try { + return setLegalHoldWithResponse(legalHold).flatMap(FluxUtil::toMono); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + /** + * Sets a legal hold on the blob. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHoldWithResponse#boolean} + * + * @param legalHold Whether or not you want a legal hold on the blob. + * @return A reactive response containing the legal hold result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setLegalHoldWithResponse(boolean legalHold) { + try { + return withContext(context -> setLegalHoldWithResponse(legalHold, context)); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + Mono> setLegalHoldWithResponse(boolean legalHold, Context context) { + context = context == null ? Context.NONE : context; + return this.azureBlobStorage.getBlobs().setLegalHoldWithResponseAsync(containerName, blobName, + legalHold, null, null, + context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) + .map(response -> new SimpleResponse<>(response, + new BlobLegalHoldResult(response.getDeserializedHeaders().isXMsLegalHold()))); + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java index 2b5ed3c1b8fda..343ba77368cb2 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java @@ -20,6 +20,8 @@ import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.BlobDownloadContentAsyncResponse; import com.azure.storage.blob.models.BlobDownloadContentResponse; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; +import com.azure.storage.blob.models.BlobLegalHoldResult; import com.azure.storage.blob.models.ConsistentReadControl; import com.azure.storage.blob.options.BlobBeginCopyOptions; import com.azure.storage.blob.options.BlobCopyFromUrlOptions; @@ -1527,4 +1529,118 @@ public BlobQueryResponse queryWithResponse(BlobQueryOptions queryOptions, Durati return blockWithOptionalTimeout(download, timeout); } + + /** + * Sets the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy} + * + * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. + * @return The immutability policy. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobImmutabilityPolicy setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) { + return setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, Context.NONE).getValue(); + } + + /** + * Sets the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions-Duration-Context} + * + * @param immutabilityPolicy {@link BlobImmutabilityPolicy The immutability policy}. + * @param requestConditions {@link BlobRequestConditions} + * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A response containing the immutability policy. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, + BlobRequestConditions requestConditions, Duration timeout, Context context) { + Mono> response = client.setImmutabilityPolicyWithResponse(immutabilityPolicy, + requestConditions, context); + + return blockWithOptionalTimeout(response, timeout); + } + + /** + * Delete the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicy} + * + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteImmutabilityPolicy() { + deleteImmutabilityPolicyWithResponse(null, Context.NONE).getValue(); + } + + /** + * Delete the immutability policy on a blob, blob snapshot or blob version. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicyWithResponse#Duration-Context} + * + * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A response containing the immutability policy. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteImmutabilityPolicyWithResponse(Duration timeout, Context context) { + Mono> response = client.deleteImmutabilityPolicyWithResponse(context); + + return blockWithOptionalTimeout(response, timeout); + } + + /** + * Sets a legal hold on the blob. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.setLegalHold#boolean} + * + * @param legalHold Whether or not you want a legal hold on the blob. + * @return The legal hold result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobLegalHoldResult setLegalHold(boolean legalHold) { + return setLegalHoldWithResponse(legalHold, null, Context.NONE).getValue(); + } + + /** + * Sets a legal hold on the blob. + *

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with + * immutable storage with versioning enabled to call this API.

+ * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.setLegalHoldWithResponse#boolean-Duration-Context} + * + * @param legalHold Whether or not you want a legal hold on the blob. + * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A response containing the legal hold result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setLegalHoldWithResponse(boolean legalHold, Duration timeout, Context context) { + Mono> response = client.setLegalHoldWithResponse(legalHold, context); + + return blockWithOptionalTimeout(response, timeout); + } } diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java index 25dd01dc286e6..64c8ea9c06d44 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobAsyncClient.java @@ -20,6 +20,7 @@ import com.azure.storage.blob.implementation.models.EncryptionScope; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRange; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.BlockBlobItem; @@ -261,13 +262,16 @@ Mono> uploadWithResponse(BlockBlobSimpleUploadOptions op BlobRequestConditions requestConditions = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); context = context == null ? Context.NONE : context; + BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); return this.azureBlobStorage.getBlockBlobs().uploadWithResponseAsync(containerName, blobName, options.getLength(), data, null, options.getContentMd5(), options.getMetadata(), requestConditions.getLeaseId(), options.getTier(), requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - tagsToString(options.getTags()), null, null, null, options.getHeaders(), getCustomerProvidedKey(), + tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), + options.isLegalHold(), options.getHeaders(), getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { BlockBlobsUploadHeaders hd = rb.getDeserializedHeaders(); @@ -387,7 +391,7 @@ Mono> uploadFromUrlWithResponse(BlobUploadFromUrlOptions sourceRequestConditions.getIfMatch(), sourceRequestConditions.getIfNoneMatch(), sourceRequestConditions.getTagsConditions(), null, options.getContentMd5(), tagsToString(options.getTags()), - options.isCopySourceBlobProperties(), options.getHeaders(), getCustomerProvidedKey(), encryptionScope, + options.isCopySourceBlobProperties(), null, options.getHeaders(), getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { BlockBlobsPutBlobFromUrlHeaders hd = rb.getDeserializedHeaders(); @@ -554,7 +558,7 @@ Mono> stageBlockFromUrlWithResponse(String base64BlockId, String return this.azureBlobStorage.getBlockBlobs().stageBlockFromURLWithResponseAsync(containerName, blobName, base64BlockId, 0, url, sourceRange.toHeaderValue(), sourceContentMd5, null, null, leaseId, sourceRequestConditions.getIfModifiedSince(), sourceRequestConditions.getIfUnmodifiedSince(), - sourceRequestConditions.getIfMatch(), sourceRequestConditions.getIfNoneMatch(), null, + sourceRequestConditions.getIfMatch(), sourceRequestConditions.getIfNoneMatch(), null, null, getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(response -> new SimpleResponse<>(response, null)); @@ -752,13 +756,16 @@ Mono> commitBlockListWithResponse(BlockBlobCommitBlockLi BlobRequestConditions requestConditions = options.getRequestConditions() == null ? new BlobRequestConditions() : options.getRequestConditions(); context = context == null ? Context.NONE : context; + BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); return this.azureBlobStorage.getBlockBlobs().commitBlockListWithResponseAsync(containerName, blobName, new BlockLookupList().setLatest(options.getBase64BlockIds()), null, null, null, options.getMetadata(), requestConditions.getLeaseId(), options.getTier(), requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), null, - tagsToString(options.getTags()), null, null, null, options.getHeaders(), getCustomerProvidedKey(), + tagsToString(options.getTags()), immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), + options.isLegalHold(), options.getHeaders(), getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { BlockBlobsCommitBlockListHeaders hd = rb.getDeserializedHeaders(); diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java index 013f067bd9e74..74d7a8bee8024 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/PageBlobAsyncClient.java @@ -25,6 +25,7 @@ import com.azure.storage.blob.implementation.models.PageBlobsUploadPagesHeaders; import com.azure.storage.blob.implementation.util.ModelHelper; import com.azure.storage.blob.models.BlobHttpHeaders; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; import com.azure.storage.blob.models.BlobRange; import com.azure.storage.blob.models.BlobRequestConditions; import com.azure.storage.blob.models.CopyStatusType; @@ -246,13 +247,16 @@ Mono> createWithResponse(PageBlobCreateOptions options, C new IllegalArgumentException("SequenceNumber must be greater than or equal to 0.")); } context = context == null ? Context.NONE : context; + BlobImmutabilityPolicy immutabilityPolicy = options.getImmutabilityPolicy() == null + ? new BlobImmutabilityPolicy() : options.getImmutabilityPolicy(); return this.azureBlobStorage.getPageBlobs().createWithResponseAsync(containerName, blobName, 0, options.getSize(), null, null, options.getMetadata(), requestConditions.getLeaseId(), requestConditions.getIfModifiedSince(), requestConditions.getIfUnmodifiedSince(), requestConditions.getIfMatch(), requestConditions.getIfNoneMatch(), requestConditions.getTagsConditions(), - options.getSequenceNumber(), null, tagsToString(options.getTags()), null, null, null, options.getHeaders(), - getCustomerProvidedKey(), encryptionScope, + options.getSequenceNumber(), null, tagsToString(options.getTags()), + immutabilityPolicy.getExpiryTime(), immutabilityPolicy.getPolicyMode(), options.isLegalHold(), + options.getHeaders(), getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { PageBlobsCreateHeaders hd = rb.getDeserializedHeaders(); @@ -470,7 +474,7 @@ Mono> uploadPagesFromUrlWithResponse(PageRange range, Str destRequestConditions.getIfMatch(), destRequestConditions.getIfNoneMatch(), destRequestConditions.getTagsConditions(), sourceRequestConditions.getIfModifiedSince(), sourceRequestConditions.getIfUnmodifiedSince(), sourceRequestConditions.getIfMatch(), - sourceRequestConditions.getIfNoneMatch(), null, getCustomerProvidedKey(), encryptionScope, + sourceRequestConditions.getIfNoneMatch(), null, null, getCustomerProvidedKey(), encryptionScope, context.addData(AZ_TRACING_NAMESPACE_KEY, STORAGE_TRACING_NAMESPACE_VALUE)) .map(rb -> { PageBlobsUploadPagesFromURLHeaders hd = rb.getDeserializedHeaders(); diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java index f8d59599cb586..244a47f6cefde 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobAsyncClientBaseJavaDocCodeSnippets.java @@ -11,6 +11,8 @@ import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.blob.models.AccessTier; import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.options.BlobBeginCopyOptions; import com.azure.storage.blob.options.BlobCopyFromUrlOptions; import com.azure.storage.blob.models.BlobCopyInfo; @@ -736,4 +738,60 @@ public void queryWithResponse() { }); // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.queryWithResponse#BlobQueryOptions } + + /** + * Code snippet for {@link BlobAsyncClientBase#setImmutabilityPolicy(BlobImmutabilityPolicy)} and + * {@link BlobAsyncClientBase#setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy, BlobRequestConditions)} + */ + public void setImmutabilityPolicy() { + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy + BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy() + .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) + .setExpiryTime(OffsetDateTime.now().plusDays(1)); + client.setImmutabilityPolicy(policy).subscribe(response -> System.out.println("Completed. Set immutability " + + "policy to " + response.getPolicyMode())); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy + + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions + BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy() + .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) + .setExpiryTime(OffsetDateTime.now().plusDays(1)); + BlobRequestConditions requestConditions = new BlobRequestConditions() + .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)); + client.setImmutabilityPolicyWithResponse(immutabilityPolicy, requestConditions).subscribe(response -> + System.out.println("Completed. Set immutability policy to " + response.getValue().getPolicyMode())); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions + } + + /** + * Code snippet for {@link BlobAsyncClientBase#deleteImmutabilityPolicy()} and + * {@link BlobAsyncClientBase#deleteImmutabilityPolicyWithResponse()} + */ + public void deleteImmutabilityPolicy() { + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicy + client.deleteImmutabilityPolicy().subscribe(response -> System.out.println("Completed immutability policy" + + " deletion.")); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicy + + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicyWithResponse + client.deleteImmutabilityPolicyWithResponse().subscribe(response -> + System.out.println("Delete immutability policy completed with status: " + response.getStatusCode())); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteImmutabilityPolicyWithResponse + } + + /** + * Code snippet for {@link BlobAsyncClientBase#setLegalHold(boolean)} and + * {@link BlobAsyncClientBase#setLegalHoldWithResponse(boolean)} + */ + public void setLegalHold() { + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHold#boolean + client.setLegalHold(true).subscribe(response -> System.out.println("Legal hold status: " + + response.hasLegalHold())); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHold#boolean + + // BEGIN: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHoldWithResponse#boolean + client.setLegalHoldWithResponse(true).subscribe(response -> + System.out.println("Legal hold status: " + response.getValue().hasLegalHold())); + // END: com.azure.storage.blob.specialized.BlobAsyncClientBase.setLegalHoldWithResponse#boolean + } } diff --git a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java index 0b90402ac35ad..059e2c2ef7194 100644 --- a/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java +++ b/sdk/storage/azure-storage-blob/src/samples/java/com/azure/storage/blob/specialized/BlobClientBaseJavaDocCodeSnippets.java @@ -4,6 +4,7 @@ package com.azure.storage.blob.specialized; import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.polling.LongRunningOperationStatus; @@ -12,6 +13,8 @@ import com.azure.storage.blob.BlobServiceClientBuilder; import com.azure.storage.blob.models.BlobBeginCopySourceRequestConditions; import com.azure.storage.blob.models.BlobDownloadContentResponse; +import com.azure.storage.blob.models.BlobImmutabilityPolicy; +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode; import com.azure.storage.blob.options.BlobBeginCopyOptions; import com.azure.storage.blob.options.BlobCopyFromUrlOptions; import com.azure.storage.blob.models.BlobProperties; @@ -705,4 +708,60 @@ public void queryWithResponse() { .getStatusCode()); // END: com.azure.storage.blob.specialized.BlobClientBase.queryWithResponse#BlobQueryOptions-Duration-Context } + + /** + * Code snippet for {@link BlobClientBase#setImmutabilityPolicy(BlobImmutabilityPolicy)} and + * {@link BlobClientBase#setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy, BlobRequestConditions, Duration, Context)} + */ + public void setImmutabilityPolicy() { + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy + BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy() + .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) + .setExpiryTime(OffsetDateTime.now().plusDays(1)); + BlobImmutabilityPolicy setPolicy = client.setImmutabilityPolicy(policy); + System.out.println("Successfully completed setting the immutability policy"); + // END: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicy#BlobImmutabilityPolicy + + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions-Duration-Context + BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy() + .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED) + .setExpiryTime(OffsetDateTime.now().plusDays(1)); + BlobRequestConditions requestConditions = new BlobRequestConditions() + .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)); + Response response = client.setImmutabilityPolicyWithResponse(immutabilityPolicy, + requestConditions, timeout, new Context(key1, value1)); + System.out.println("Successfully completed setting the immutability policy"); + // END: com.azure.storage.blob.specialized.BlobClientBase.setImmutabilityPolicyWithResponse#BlobImmutabilityPolicy-BlobRequestConditions-Duration-Context + } + + /** + * Code snippet for {@link BlobClientBase#deleteImmutabilityPolicy()} and + * {@link BlobClientBase#deleteImmutabilityPolicyWithResponse(Duration, Context)} + */ + public void deleteImmutabilityPolicy() { + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicy + client.deleteImmutabilityPolicy(); + System.out.println("Completed immutability policy deletion."); + // END: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicy + + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicyWithResponse#Duration-Context + System.out.println("Delete immutability policy completed with status: " + + client.deleteImmutabilityPolicyWithResponse(timeout, new Context(key1, value1)).getStatusCode()); + // END: com.azure.storage.blob.specialized.BlobClientBase.deleteImmutabilityPolicyWithResponse#Duration-Context + } + + /** + * Code snippet for {@link BlobClientBase#setLegalHold(boolean)} and + * {@link BlobClientBase#setLegalHoldWithResponse(boolean, Duration, Context)} + */ + public void setLegalHold() { + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setLegalHold#boolean + System.out.println("Legal hold status: " + client.setLegalHold(true)); + // END: com.azure.storage.blob.specialized.BlobClientBase.setLegalHold#boolean + + // BEGIN: com.azure.storage.blob.specialized.BlobClientBase.setLegalHoldWithResponse#boolean-Duration-Context + System.out.println("Legal hold status: " + client.setLegalHoldWithResponse(true, timeout, + new Context(key1, value1))); + // END: com.azure.storage.blob.specialized.BlobClientBase.setLegalHoldWithResponse#boolean-Duration-Context + } } diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy index 65f283ca5a009..5cebc5661fa7d 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/APISpec.groovy @@ -774,7 +774,7 @@ class APISpec extends StorageSpec { } def getPollingDuration(long liveTestDurationInMillis) { - return (env.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(10) : Duration.ofMillis(liveTestDurationInMillis) + return (env.testMode == TestMode.PLAYBACK) ? Duration.ofMillis(1) : Duration.ofMillis(liveTestDurationInMillis) } def getPerCallVersionPolicy() { diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTest.groovy index aceeea173203f..2281d0e4e65a9 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobServiceSasModelsTest.groovy @@ -38,23 +38,25 @@ class BlobServiceSasModelsTest extends Specification { .setListPermission(list) .setMovePermission(move) .setExecutePermission(execute) + .setImmutabilityPolicyPermission(setImmutabilityPolicy) expect: perms.toString() == expectedString where: - read | write | delete | create | add | deleteVersion | tags | list | move | execute || expectedString - true | false | false | false | false | false | false | false | false | false || "r" - false | true | false | false | false | false | false | false | false | false || "w" - false | false | true | false | false | false | false | false | false | false || "d" - false | false | false | true | false | false | false | false | false | false || "c" - false | false | false | false | true | false | false | false | false | false || "a" - false | false | false | false | false | true | false | false | false | false || "x" - false | false | false | false | false | false | true | false | false | false || "t" - false | false | false | false | false | false | false | true | false | false || "l" - false | false | false | false | false | false | false | false | true | false || "m" - false | false | false | false | false | false | false | false | false | true || "e" - true | true | true | true | true | true | true | true | true | true || "racwdxltme" + read | write | delete | create | add | deleteVersion | tags | list | move | execute | setImmutabilityPolicy || expectedString + true | false | false | false | false | false | false | false | false | false | false || "r" + false | true | false | false | false | false | false | false | false | false | false || "w" + false | false | true | false | false | false | false | false | false | false | false || "d" + false | false | false | true | false | false | false | false | false | false | false || "c" + false | false | false | false | true | false | false | false | false | false | false || "a" + false | false | false | false | false | true | false | false | false | false | false || "x" + false | false | false | false | false | false | true | false | false | false | false || "t" + false | false | false | false | false | false | false | true | false | false | false || "l" + false | false | false | false | false | false | false | false | true | false | false || "m" + false | false | false | false | false | false | false | false | false | true | false || "e" + false | false | false | false | false | false | false | false | false | false | true || "i" + true | true | true | true | true | true | true | true | true | true | true || "racwdxltmei" } @Unroll @@ -73,21 +75,23 @@ class BlobServiceSasModelsTest extends Specification { perms.hasListPermission() == list perms.hasMovePermission() == move perms.hasExecutePermission() == execute + perms.hasImmutabilityPolicyPermission() == setImmutabilityPolicy where: - permString || read | write | delete | create | add | deleteVersion | tags | list | move | execute - "r" || true | false | false | false | false | false | false | false | false | false - "w" || false | true | false | false | false | false | false | false | false | false - "d" || false | false | true | false | false | false | false | false | false | false - "c" || false | false | false | true | false | false | false | false | false | false - "a" || false | false | false | false | true | false | false | false | false | false - "x" || false | false | false | false | false | true | false | false | false | false - "t" || false | false | false | false | false | false | true | false | false | false - "l" || false | false | false | false | false | false | false | true | false | false - "m" || false | false | false | false | false | false | false | false | true | false - "e" || false | false | false | false | false | false | false | false | false | true - "racwdxltme" || true | true | true | true | true | true | true | true | true | true - "dtcxewlrma" || true | true | true | true | true | true | true | true | true | true + permString || read | write | delete | create | add | deleteVersion | tags | list | move | execute | setImmutabilityPolicy + "r" || true | false | false | false | false | false | false | false | false | false | false + "w" || false | true | false | false | false | false | false | false | false | false | false + "d" || false | false | true | false | false | false | false | false | false | false | false + "c" || false | false | false | true | false | false | false | false | false | false | false + "a" || false | false | false | false | true | false | false | false | false | false | false + "x" || false | false | false | false | false | true | false | false | false | false | false + "t" || false | false | false | false | false | false | true | false | false | false | false + "l" || false | false | false | false | false | false | false | true | false | false | false + "m" || false | false | false | false | false | false | false | false | true | false | false + "e" || false | false | false | false | false | false | false | false | false | true | false + "i" || false | false | false | false | false | false | false | false | false | false | true + "racwdxltmei" || true | true | true | true | true | true | true | true | true | true | true + "dtcxiewlrma" || true | true | true | true | true | true | true | true | true | true | true } def "BlobSASPermissions parse IA"() { @@ -120,23 +124,25 @@ class BlobServiceSasModelsTest extends Specification { .setTagsPermission(tags) .setMovePermission(move) .setExecutePermission(execute) + .setImmutabilityPolicyPermission(setImmutabilityPolicy) expect: perms.toString() == expectedString where: - read | write | delete | create | add | deleteVersion | tags | list | move | execute || expectedString - true | false | false | false | false | false | false | false | false | false || "r" - false | true | false | false | false | false | false | false | false | false || "w" - false | false | true | false | false | false | false | false | false | false || "d" - false | false | false | true | false | false | false | false | false | false || "c" - false | false | false | false | true | false | false | false | false | false || "a" - false | false | false | false | false | true | false | false | false | false || "x" - false | false | false | false | false | false | true | false | false | false || "t" - false | false | false | false | false | false | false | true | false | false || "l" - false | false | false | false | false | false | false | false | true | false || "m" - false | false | false | false | false | false | false | false | false | true || "e" - true | true | true | true | true | true | true | true | true | true || "racwdxltme" + read | write | delete | create | add | deleteVersion | tags | list | move | execute | setImmutabilityPolicy || expectedString + true | false | false | false | false | false | false | false | false | false | false || "r" + false | true | false | false | false | false | false | false | false | false | false || "w" + false | false | true | false | false | false | false | false | false | false | false || "d" + false | false | false | true | false | false | false | false | false | false | false || "c" + false | false | false | false | true | false | false | false | false | false | false || "a" + false | false | false | false | false | true | false | false | false | false | false || "x" + false | false | false | false | false | false | true | false | false | false | false || "t" + false | false | false | false | false | false | false | true | false | false | false || "l" + false | false | false | false | false | false | false | false | true | false | false || "m" + false | false | false | false | false | false | false | false | false | true | false || "e" + false | false | false | false | false | false | false | false | false | false | true || "i" + true | true | true | true | true | true | true | true | true | true | true || "racwdxltmei" } @Unroll @@ -155,21 +161,23 @@ class BlobServiceSasModelsTest extends Specification { perms.hasListPermission() == list perms.hasMovePermission() == move perms.hasExecutePermission() == execute + perms.hasImmutabilityPolicyPermission() == setImmutabilityPolicy where: - permString || read | write | delete | create | add | deleteVersion | tags | list | move | execute - "r" || true | false | false | false | false | false | false | false | false | false - "w" || false | true | false | false | false | false | false | false | false | false - "d" || false | false | true | false | false | false | false | false | false | false - "c" || false | false | false | true | false | false | false | false | false | false - "a" || false | false | false | false | true | false | false | false | false | false - "x" || false | false | false | false | false | true | false | false | false | false - "t" || false | false | false | false | false | false | true | false | false | false - "l" || false | false | false | false | false | false | false | true | false | false - "m" || false | false | false | false | false | false | false | false | true | false - "e" || false | false | false | false | false | false | false | false | false | true - "racwdxltme" || true | true | true | true | true | true | true | true | true | true - "dtcxewlrma" || true | true | true | true | true | true | true | true | true | true + permString || read | write | delete | create | add | deleteVersion | tags | list | move | execute | setImmutabilityPolicy + "r" || true | false | false | false | false | false | false | false | false | false | false + "w" || false | true | false | false | false | false | false | false | false | false | false + "d" || false | false | true | false | false | false | false | false | false | false | false + "c" || false | false | false | true | false | false | false | false | false | false | false + "a" || false | false | false | false | true | false | false | false | false | false | false + "x" || false | false | false | false | false | true | false | false | false | false | false + "t" || false | false | false | false | false | false | true | false | false | false | false + "l" || false | false | false | false | false | false | false | true | false | false | false + "m" || false | false | false | false | false | false | false | false | true | false | false + "e" || false | false | false | false | false | false | false | false | false | true | false + "i" || false | false | false | false | false | false | false | false | false | false | true + "racwdxltmei" || true | true | true | true | true | true | true | true | true | true | true + "dticxewlrma" || true | true | true | true | true | true | true | true | true | true | true } def "ContainerSASPermissions parse IA"() { diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy index af5dacfac3a03..88d71669d3d48 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKNTest.groovy @@ -1,6 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.storage.blob -import com.azure.core.test.TestMode import com.azure.storage.blob.models.BlobContainerEncryptionScope import com.azure.storage.blob.models.BlobItem import com.azure.storage.blob.models.BlobStorageException diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy index aa158b5a79ceb..01ae2cdf01c79 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/CPKTest.groovy @@ -1,7 +1,8 @@ -package com.azure.storage.blob +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.blob -import com.azure.core.test.TestMode import com.azure.storage.blob.models.CustomerProvidedKey import com.azure.storage.blob.models.PageRange import com.azure.storage.blob.sas.BlobSasPermission diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy new file mode 100644 index 0000000000000..aaf441258acd9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTest.groovy @@ -0,0 +1,683 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob + +import com.azure.core.credential.TokenCredential +import com.azure.core.http.HttpHeaders +import com.azure.core.http.HttpMethod +import com.azure.core.http.HttpPipeline +import com.azure.core.http.HttpPipelineBuilder +import com.azure.core.http.HttpRequest +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy +import com.azure.core.test.TestMode +import com.azure.identity.EnvironmentCredentialBuilder +import com.azure.storage.blob.models.BlobErrorCode +import com.azure.storage.blob.models.BlobImmutabilityPolicy +import com.azure.storage.blob.models.BlobImmutabilityPolicyMode +import com.azure.storage.blob.models.BlobListDetails +import com.azure.storage.blob.models.BlobRequestConditions +import com.azure.storage.blob.models.BlobStorageException +import com.azure.storage.blob.models.LeaseStateType +import com.azure.storage.blob.models.ListBlobContainersOptions +import com.azure.storage.blob.models.ListBlobsOptions +import com.azure.storage.blob.models.ParallelTransferOptions +import com.azure.storage.blob.models.PublicAccessType +import com.azure.storage.blob.options.AppendBlobCreateOptions +import com.azure.storage.blob.options.BlobBeginCopyOptions +import com.azure.storage.blob.options.BlobBreakLeaseOptions +import com.azure.storage.blob.options.BlobCopyFromUrlOptions +import com.azure.storage.blob.options.BlobParallelUploadOptions +import com.azure.storage.blob.options.BlockBlobCommitBlockListOptions +import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions +import com.azure.storage.blob.options.PageBlobCreateOptions +import com.azure.storage.blob.sas.BlobContainerSasPermission +import com.azure.storage.blob.sas.BlobSasPermission +import com.azure.storage.blob.sas.BlobServiceSasSignatureValues +import com.azure.storage.common.sas.AccountSasPermission +import com.azure.storage.common.sas.AccountSasResourceType +import com.azure.storage.common.sas.AccountSasService +import com.azure.storage.common.sas.AccountSasSignatureValues +import com.azure.storage.common.test.shared.extensions.LiveOnly +import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion +import com.fasterxml.jackson.databind.ObjectMapper +import reactor.core.publisher.Flux +import spock.lang.ResourceLock +import spock.lang.Unroll + +import java.nio.ByteBuffer +import java.nio.charset.StandardCharsets +import java.time.Duration +import java.time.temporal.ChronoUnit + +@ResourceLock("ManagementPlaneThrottling") +class ImmutableStorageWithVersioningTest extends APISpec { + + private BlobContainerClient vlwContainer; + private BlobClient vlwBlob + private String accountName = env.primaryAccount.name + private String containerName + private String resourceGroupName = "XClient" + private String subscriptionId = "ba45b233-e2ef-4169-8808-49eb0d8eba0d" + private String apiVersion = "2021-04-01" + private TokenCredential credential = new EnvironmentCredentialBuilder().build() + private BearerTokenAuthenticationPolicy credentialPolicy = new BearerTokenAuthenticationPolicy(credential, "https://management.azure.com/.default") + + def setup() { + containerName = generateContainerName() + + if (env.testMode != TestMode.PLAYBACK) { + String url = String.format("https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" + + "Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s?api-version=%s", subscriptionId, + resourceGroupName, accountName, containerName, apiVersion) + HttpPipeline httpPipeline = new HttpPipelineBuilder() + .policies(credentialPolicy) + .httpClient(getHttpClient()) + .build() + + def immutableStorageWithVersioning = new ImmutableStorageWithVersioning() + immutableStorageWithVersioning.enabled = true + def properties = new Properties() + properties.immutableStorageWithVersioning = immutableStorageWithVersioning + def body = new Body() + body.id = String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/" + + "%s/blobServices/default/containers/%s", subscriptionId, resourceGroupName, accountName, containerName) + body.name = containerName + body.type = "Microsoft.Storage/storageAccounts/blobServices/containers" + body.properties = properties + + String serializedBody = new ObjectMapper().writeValueAsString(body) + + httpPipeline.send(new HttpRequest(HttpMethod.PUT, new URL(url), new HttpHeaders(), + Flux.just(ByteBuffer.wrap(serializedBody.getBytes(StandardCharsets.UTF_8))))) + .block() + } + + vlwContainer = primaryBlobServiceClient.getBlobContainerClient(containerName) + vlwBlob = vlwContainer.getBlobClient(generateBlobName()) + vlwBlob.upload(new ByteArrayInputStream(new byte[0]), 0) + } + + private final class Body { + public String id + public String name + public String type + public Properties properties + } + private final class Properties { + public ImmutableStorageWithVersioning immutableStorageWithVersioning + } + private final class ImmutableStorageWithVersioning { + public boolean enabled + } + + def cleanup() { + + if (env.testMode != TestMode.PLAYBACK) { + HttpPipeline httpPipeline = new HttpPipelineBuilder() + .policies(credentialPolicy) + .httpClient(getHttpClient()) + .build() + def cleanupClient = new BlobServiceClientBuilder() + .httpClient(getHttpClient()) + .credential(env.primaryAccount.credential) + .endpoint(env.primaryAccount.blobEndpoint) + .buildClient() + + def options = new ListBlobContainersOptions().setPrefix(namer.getResourcePrefix()) + for (def container : cleanupClient.listBlobContainers(options, null)) { + def containerClient = cleanupClient.getBlobContainerClient(container.getName()) + + if (container.getProperties().getLeaseState() == LeaseStateType.LEASED) { + createLeaseClient(containerClient).breakLeaseWithResponse(new BlobBreakLeaseOptions().setBreakPeriod(Duration.ofSeconds(0)), null, null) + } + if (container.getProperties().isImmutableStorageWithVersioningEnabled()) { + options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)) + for (def blob: containerClient.listBlobs(options, null)) { + def blobClient = containerClient.getBlobClient(blob.getName()) + if (blob.getProperties().hasLegalHold()) { + blobClient.setLegalHold(false) + } + if (blob.getProperties().getImmutabilityPolicyMode() != null) { + sleepIfRecord(5 * 1000) + blobClient.deleteImmutabilityPolicy() + } + blobClient.delete() + } + } + + String url = String.format("https://management.azure.com/subscriptions/%s/resourceGroups/%s/providers/" + + "Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s?api-version=%s", subscriptionId, + resourceGroupName, accountName, container.getName(), apiVersion) + httpPipeline.send(new HttpRequest(HttpMethod.DELETE, new URL(url), new HttpHeaders(), Flux.empty())) + .block() + } + } + + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "set immutability policy min"() { + setup: + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + + when: + def response = vlwBlob.setImmutabilityPolicy(immutabilityPolicy) + + then: + expectedImmutabilityPolicyExpiry == response.getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED == response.getPolicyMode() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + @Unroll + def "set immutability policy"() { + setup: + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(policyMode) + + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + + when: "set immutability policy" + def response = vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, null).getValue() + + then: + expectedImmutabilityPolicyExpiry == response.getExpiryTime() + policyMode == response.getPolicyMode() + + when: "get properties" + response = vlwBlob.getProperties() + + then: + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + policyMode.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + + when: "list blob" + def options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)) + response = vlwContainer.listBlobs(options, null).iterator() + + then: + def blob = response.next() + !response.hasNext() + blob.getName() == vlwBlob.getBlobName() + expectedImmutabilityPolicyExpiry == blob.getProperties().getImmutabilityPolicy().getExpiryTime() + policyMode.toString() == blob.getProperties().getImmutabilityPolicy().getPolicyMode().toString() + + + where: + policyMode || _ + BlobImmutabilityPolicyMode.UNLOCKED || _ + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + @Unroll + def "set immutability policy AC"() { + setup: + def bac = new BlobRequestConditions() + .setIfUnmodifiedSince(unmodified) + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + def response = vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac, null, null) + + then: + response.getStatusCode() == 200 + + where: + unmodified || _ + null || _ + newDate || _ + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "set immutability policy AC fail"() { + setup: + def bac = new BlobRequestConditions() + .setIfUnmodifiedSince(oldDate) + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, bac, null, null) + + then: + def e = thrown(BlobStorageException) + e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "set immutability policy error"() { + setup: + def blob = vlwContainer.getBlobClient(generateBlobName()) + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + blob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, null) + + then: + def e = thrown(BlobStorageException) + e.getErrorCode() == BlobErrorCode.BLOB_NOT_FOUND + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "set immutability policy IA"() { + setup: + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.MUTABLE) + + when: + vlwBlob.setImmutabilityPolicyWithResponse(immutabilityPolicy, null, null, null) + + then: + def e = thrown(IllegalArgumentException) + e.getMessage() == "immutabilityPolicy.policyMode must be Locked or Unlocked" + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "delete immutability policy min"() { + setup: + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + vlwBlob.setImmutabilityPolicy(immutabilityPolicy) + + when: + vlwBlob.deleteImmutabilityPolicy() + + then: + def properties = vlwBlob.getProperties() + properties.getImmutabilityPolicy().getPolicyMode() == null + properties.getImmutabilityPolicy().getExpiryTime() == null + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "delete immutability policy"() { + setup: + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + vlwBlob.setImmutabilityPolicy(immutabilityPolicy) + + when: + vlwBlob.deleteImmutabilityPolicyWithResponse(null, null) + + then: + def properties = vlwBlob.getProperties() + properties.getImmutabilityPolicy().getPolicyMode() == null + properties.getImmutabilityPolicy().getExpiryTime() == null + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "delete immutability policy error"() { + setup: + def blob = vlwContainer.getBlobClient(generateBlobName()) + + when: + blob.deleteImmutabilityPolicyWithResponse(null, null) + + then: + def e = thrown(BlobStorageException) + e.getErrorCode() == BlobErrorCode.BLOB_NOT_FOUND + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + @Unroll + def "set legal hold min"() { + when: + def response = vlwBlob.setLegalHold(legalHold) + + then: + response.hasLegalHold() == legalHold + + where: + legalHold || _ + true || _ + false || _ + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + @Unroll + def "set legal hold"() { + when: "set legal hold" + def response = vlwBlob.setLegalHoldWithResponse(legalHold, null, null) + + then: + response.getValue().hasLegalHold() == legalHold + + when: "get properties" + response = vlwBlob.getProperties() + + then: + legalHold == response.hasLegalHold() + + when: "list blob" + def options = new ListBlobsOptions().setDetails(new BlobListDetails().setRetrieveImmutabilityPolicy(true).setRetrieveLegalHold(true)) + response = vlwContainer.listBlobs(options, null).iterator() + + then: + def blob = response.next() + !response.hasNext() + blob.getName() == vlwBlob.getBlobName() + legalHold == blob.getProperties().hasLegalHold() + + where: + legalHold || _ + true || _ + false || _ + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "set legal hold error"() { + setup: + def blob = vlwContainer.getBlobClient(generateBlobName()) + + when: + blob.setLegalHoldWithResponse(false, null, null) + + then: + def e = thrown(BlobStorageException) + e.getErrorCode() == BlobErrorCode.BLOB_NOT_FOUND + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "container properties"() { + when: + def response = vlwContainer.getProperties() + + then: + response.isImmutableStorageWithVersioningEnabled() + + when: + response = vlwContainer.getServiceClient().listBlobContainers(new ListBlobContainersOptions().setPrefix(vlwContainer.getBlobContainerName()), null).iterator() + + then: + def container = response.next() + !response.hasNext() + container.getProperties().isImmutableStorageWithVersioningEnabled() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "append blob create"() { + setup: + def appendBlob = vlwContainer.getBlobClient(generateBlobName()).getAppendBlobClient() + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + appendBlob.createWithResponse(new AppendBlobCreateOptions() + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true), null, null) + + then: + def response = appendBlob.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "page blob create"() { + setup: + def pageBlob = vlwContainer.getBlobClient(generateBlobName()).getPageBlobClient() + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + pageBlob.createWithResponse(new PageBlobCreateOptions(512) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true), null, null) + + then: + def response = pageBlob.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "block blob commit block list"() { + setup: + def blockBlob = vlwBlob.getBlockBlobClient() + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + blockBlob.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(new ArrayList()) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true), null, null) + + then: + def response = blockBlob.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "block blob upload"() { + setup: + def blockBlob = vlwBlob.getBlockBlobClient() + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + blockBlob.uploadWithResponse(new BlockBlobSimpleUploadOptions(data.defaultFlux, data.defaultDataSize) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true), null, null) + + then: + def response = blockBlob.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + @Unroll + @LiveOnly + def "blob upload"() { + setup: + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + vlwBlob.uploadWithResponse(new BlobParallelUploadOptions(data.defaultFlux) + .setParallelTransferOptions(new ParallelTransferOptions().setBlockSizeLong(blockSize).setMaxSingleUploadSizeLong(blockSize)) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true), null, null) + + then: + def response = vlwBlob.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + + where: + blockSize || _ + 1 || _ // Tests multi-part upload + null || _ // Tests single shot upload + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "sync copy"() { + setup: + vlwContainer.setAccessPolicy(PublicAccessType.CONTAINER, null) + def destination = vlwContainer.getBlobClient(generateBlobName()).getBlockBlobClient() + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + destination.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(vlwBlob.getBlobUrl()) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true), null, null) + + then: + def response = destination.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + + cleanup: + vlwContainer.setAccessPolicy(null, null) + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "copy"() { + setup: + def destination = vlwContainer.getBlobClient(generateBlobName()).getBlockBlobClient() + def expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + + when: + def poller = destination.beginCopy(new BlobBeginCopyOptions(vlwBlob.getBlobUrl()) + .setImmutabilityPolicy(immutabilityPolicy) + .setLegalHold(true).setPollInterval(getPollingDuration(1000))) + poller.waitForCompletion() + + then: + def response = destination.getProperties() + expectedImmutabilityPolicyExpiry == response.getImmutabilityPolicy().getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getImmutabilityPolicy().getPolicyMode().toString() + response.hasLegalHold() + } + + /* SAS tests */ + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "account sas"() { + setup: + def expiryTime = namer.getUtcNow().plusDays(1) + def permissions = AccountSasPermission.parse("rwdxlacuptfi") + def service = new AccountSasService().setBlobAccess(true) + def resource = new AccountSasResourceType().setObject(true).setContainer(true) + def sasValues = new AccountSasSignatureValues(expiryTime, permissions, service, resource) + expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + def sas = primaryBlobServiceClient.generateAccountSas(sasValues) + def client = getBlobClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName()) + + when: + def response = client.setImmutabilityPolicy(immutabilityPolicy) + + then: + expectedImmutabilityPolicyExpiry == response.getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getPolicyMode().toString() + + when: + response = client.setLegalHold(false) + + then: + !response.hasLegalHold() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "container sas"() { + setup: + def expiryTime = namer.getUtcNow().plusDays(1) + def permissions = BlobContainerSasPermission.parse("racwdxltmei") + def sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions) + expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + def sas = vlwContainer.generateSas(sasValues) + def client = getBlobClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName()) + + when: + def response = client.setImmutabilityPolicy(immutabilityPolicy) + + then: + expectedImmutabilityPolicyExpiry == response.getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getPolicyMode().toString() + + when: + response = client.setLegalHold(false) + + then: + !response.hasLegalHold() + } + + @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02") + def "blob sas"() { + setup: + def expiryTime = namer.getUtcNow().plusDays(1) + def permissions = BlobSasPermission.parse("racwdxtlmei") + def sasValues = new BlobServiceSasSignatureValues(expiryTime, permissions) + expiryTime = getNamer().getUtcNow().plusSeconds(2) + // The service rounds Immutability Policy Expiry to the nearest second. + def expectedImmutabilityPolicyExpiry = expiryTime.truncatedTo(ChronoUnit.SECONDS) + def immutabilityPolicy = new BlobImmutabilityPolicy() + .setExpiryTime(expiryTime) + .setPolicyMode(BlobImmutabilityPolicyMode.UNLOCKED) + def sas = vlwBlob.generateSas(sasValues) + def client = getBlobClient(sas, vlwContainer.getBlobContainerUrl(), vlwBlob.getBlobName()) + + when: + def response = client.setImmutabilityPolicy(immutabilityPolicy) + + then: + expectedImmutabilityPolicyExpiry == response.getExpiryTime() + BlobImmutabilityPolicyMode.UNLOCKED.toString() == response.getPolicyMode().toString() + + when: + response = client.setLegalHold(false) + + then: + !response.hasLegalHold() + } + +} diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestAccountSas.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestAccountSas.json new file mode 100644 index 0000000000000..e9f77df7757a6 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestAccountSas.json @@ -0,0 +1,92 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/b3e29cea0b3e29cea2626041815d31a7ca8994aec877?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "14bcfc1d-10c3-405b-9616-8bf0cde241fe" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D921461D6D270A", + "Last-Modified" : "Thu, 27 May 2021 19:32:07 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac30a7-501e-0090-672e-53e0ac000000", + "x-ms-client-request-id" : "14bcfc1d-10c3-405b-9616-8bf0cde241fe", + "Date" : "Thu, 27 May 2021 19:32:06 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/b3e29cea1b3e29cea262102965f662e4767134970929/b3e29cea2b3e29cea26225384ffb25649a66b4fa6855", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "fae88e85-9e7a-496d-b4e0-72a072eb8fae", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:32:07 GMT", + "x-ms-version-id" : "2021-05-27T19:32:07.9900351Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:32:07 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D921461DBBA6BF", + "x-ms-request-id" : "72ac3102-501e-0090-212e-53e0ac000000", + "x-ms-client-request-id" : "fae88e85-9e7a-496d-b4e0-72a072eb8fae" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/b3e29cea1b3e29cea262102965f662e4767134970929/b3e29cea2b3e29cea26225384ffb25649a66b4fa6855?comp=immutabilityPolicies&sv=2020-10-02&ss=b&srt=co&se=2021-05-28T19%3A32%3A08Z&sp=rwdxlacuptfi&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e3bda891-4f63-44f9-bdee-33bbc4d0b3b3" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:32:10 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "72ac3124-501e-0090-3e2e-53e0ac000000", + "x-ms-client-request-id" : "e3bda891-4f63-44f9-bdee-33bbc4d0b3b3", + "Date" : "Thu, 27 May 2021 19:32:07 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/b3e29cea1b3e29cea262102965f662e4767134970929/b3e29cea2b3e29cea26225384ffb25649a66b4fa6855?comp=legalhold&sv=2020-10-02&ss=b&srt=co&se=2021-05-28T19%3A32%3A08Z&sp=rwdxlacuptfi&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "775183b6-1d16-469c-9066-c3069caecfb6" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "false", + "x-ms-request-id" : "72ac313e-501e-0090-522e-53e0ac000000", + "x-ms-client-request-id" : "775183b6-1d16-469c-9066-c3069caecfb6", + "Date" : "Thu, 27 May 2021 19:32:07 GMT" + }, + "Exception" : null + } ], + "variables" : [ "b3e29cea0b3e29cea2626041815d31a7ca8994aec877", "b3e29cea1b3e29cea262102965f662e4767134970929", "b3e29cea2b3e29cea26225384ffb25649a66b4fa6855", "2021-05-27T19:32:08.903747700Z", "2021-05-27T19:32:08.961483200Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestAppendBlobCreate.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestAppendBlobCreate.json new file mode 100644 index 0000000000000..27073964bb5fe --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestAppendBlobCreate.json @@ -0,0 +1,108 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/3acd3d2703acd3d2728d59408c3c96ff9ca2b416cacd?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "1584034e-365a-4a73-9004-14d9ae50b4ae" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F522C770", + "Last-Modified" : "Thu, 27 May 2021 19:30:59 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae7b92-a01e-002d-3a2e-5369b1000000", + "x-ms-client-request-id" : "1584034e-365a-4a73-9004-14d9ae50b4ae", + "Date" : "Thu, 27 May 2021 19:30:59 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/3acd3d2713acd3d2728d084871af8b3daca1444f8941/3acd3d2723acd3d2728d139092bed77e0a1c343f7bb0", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "35c7e1d5-ec62-468d-9527-f4b3b734d897", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:00 GMT", + "x-ms-version-id" : "2021-05-27T19:31:00.4770663Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:00 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145F57DFD67", + "x-ms-request-id" : "6fae7bfd-a01e-002d-122e-5369b1000000", + "x-ms-client-request-id" : "35c7e1d5-ec62-468d-9527-f4b3b734d897" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/3acd3d2713acd3d2728d084871af8b3daca1444f8941/3acd3d2733acd3d2728d86294aecd491f72994ce28d7", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3b14f7b2-52d0-415f-b161-c86959d97f58" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F591FE3A", + "Last-Modified" : "Thu, 27 May 2021 19:31:00 GMT", + "x-ms-version-id" : "2021-05-27T19:31:00.6081594Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae7c06-a01e-002d-1b2e-5369b1000000", + "x-ms-request-server-encrypted" : "true", + "x-ms-client-request-id" : "3b14f7b2-52d0-415f-b161-c86959d97f58", + "Date" : "Thu, 27 May 2021 19:31:00 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/3acd3d2713acd3d2728d084871af8b3daca1444f8941/3acd3d2733acd3d2728d86294aecd491f72994ce28d7", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "4141d73a-c4bb-489a-9b2a-781e0fc59f2b" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:31:03 GMT", + "x-ms-lease-state" : "available", + "x-ms-blob-committed-block-count" : "0", + "Last-Modified" : "Thu, 27 May 2021 19:31:00 GMT", + "x-ms-version-id" : "2021-05-27T19:31:00.6081594Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:31:00 GMT", + "x-ms-blob-type" : "AppendBlob", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:00 GMT", + "eTag" : "0x8D92145F591FE3A", + "x-ms-request-id" : "6fae7c1b-a01e-002d-262e-5369b1000000", + "x-ms-client-request-id" : "4141d73a-c4bb-489a-9b2a-781e0fc59f2b", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + } ], + "variables" : [ "3acd3d2703acd3d2728d59408c3c96ff9ca2b416cacd", "3acd3d2713acd3d2728d084871af8b3daca1444f8941", "3acd3d2723acd3d2728d139092bed77e0a1c343f7bb0", "3acd3d2733acd3d2728d86294aecd491f72994ce28d7", "2021-05-27T19:31:01.400830300Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlobSas.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlobSas.json new file mode 100644 index 0000000000000..97f9a20b9a2f8 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlobSas.json @@ -0,0 +1,92 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/63d094ba063d094ba06a426019282cc2a0828436da12?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "a9c65418-d204-4279-86d2-dfe3bad38288" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D9214625B1602C", + "Last-Modified" : "Thu, 27 May 2021 19:32:21 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac3c7a-501e-0090-5c2f-53e0ac000000", + "x-ms-client-request-id" : "a9c65418-d204-4279-86d2-dfe3bad38288", + "Date" : "Thu, 27 May 2021 19:32:20 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/63d094ba163d094ba06a741161e86f18e44904e199c3/63d094ba263d094ba06a02168a3a3bebddffa4bf7a64", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "bb5a8d68-ad12-4aff-ada5-075e5b536c75", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:32:21 GMT", + "x-ms-version-id" : "2021-05-27T19:32:21.9069192Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:32:21 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D9214626073308", + "x-ms-request-id" : "72ac3ce7-501e-0090-302f-53e0ac000000", + "x-ms-client-request-id" : "bb5a8d68-ad12-4aff-ada5-075e5b536c75" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/63d094ba163d094ba06a741161e86f18e44904e199c3/63d094ba263d094ba06a02168a3a3bebddffa4bf7a64?comp=immutabilityPolicies&sv=2020-10-02&se=2021-05-28T19%3A32%3A22Z&sr=b&sp=racwdxltmei&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3f108c91-d35b-47c6-b6b7-cf5093713786" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:32:24 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "72ac3cfb-501e-0090-412f-53e0ac000000", + "x-ms-client-request-id" : "3f108c91-d35b-47c6-b6b7-cf5093713786", + "Date" : "Thu, 27 May 2021 19:32:21 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/63d094ba163d094ba06a741161e86f18e44904e199c3/63d094ba263d094ba06a02168a3a3bebddffa4bf7a64?comp=legalhold&sv=2020-10-02&se=2021-05-28T19%3A32%3A22Z&sr=b&sp=racwdxltmei&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "fa29218b-a6ca-45b9-a570-0a978e142412" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "false", + "x-ms-request-id" : "72ac3d0d-501e-0090-522f-53e0ac000000", + "x-ms-client-request-id" : "fa29218b-a6ca-45b9-a570-0a978e142412", + "Date" : "Thu, 27 May 2021 19:32:21 GMT" + }, + "Exception" : null + } ], + "variables" : [ "63d094ba063d094ba06a426019282cc2a0828436da12", "63d094ba163d094ba06a741161e86f18e44904e199c3", "63d094ba263d094ba06a02168a3a3bebddffa4bf7a64", "2021-05-27T19:32:22.823801200Z", "2021-05-27T19:32:22.840795800Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlockBlobCommitBlockList.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlockBlobCommitBlockList.json new file mode 100644 index 0000000000000..cdff28d550175 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlockBlobCommitBlockList.json @@ -0,0 +1,112 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/0d73644400d7364443cc83999b6206e8df4f64657b82?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "ee051c03-d731-43ac-9efe-ab1ef517b3f1" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D921460AEBBD0A", + "Last-Modified" : "Thu, 27 May 2021 19:31:36 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac1421-501e-0090-7b2e-53e0ac000000", + "x-ms-client-request-id" : "ee051c03-d731-43ac-9efe-ab1ef517b3f1", + "Date" : "Thu, 27 May 2021 19:31:35 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/0d73644410d7364443cc189079debf198110c435eaca/0d73644420d7364443cc62709f00d9176b9494fa1a48", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "7b4d4a30-689c-4c45-b808-07f480741bbf", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:37 GMT", + "x-ms-version-id" : "2021-05-27T19:31:37.0370424Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:36 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D921460B489978", + "x-ms-request-id" : "72ac1490-501e-0090-4f2e-53e0ac000000", + "x-ms-client-request-id" : "7b4d4a30-689c-4c45-b808-07f480741bbf" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/0d73644410d7364443cc189079debf198110c435eaca/0d73644420d7364443cc62709f00d9176b9494fa1a48?comp=blocklist", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e017e175-17fa-4c1d-a2ac-7c136d81ece6", + "Content-Type" : "application/xml" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "p1vsGtjjPsk=", + "Last-Modified" : "Thu, 27 May 2021 19:31:37 GMT", + "x-ms-version-id" : "2021-05-27T19:31:37.3042321Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:36 GMT", + "eTag" : "0x8D921460B711065", + "x-ms-request-id" : "72ac14fd-501e-0090-2b2e-53e0ac000000", + "x-ms-client-request-id" : "e017e175-17fa-4c1d-a2ac-7c136d81ece6" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/0d73644410d7364443cc189079debf198110c435eaca/0d73644420d7364443cc62709f00d9176b9494fa1a48", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "286f7a1b-101d-49b7-a905-73241cd65fc6" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:31:37 GMT", + "x-ms-version-id" : "2021-05-27T19:31:37.3042321Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-blob-type" : "BlockBlob", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:37 GMT", + "eTag" : "0x8D921460B711065", + "x-ms-request-id" : "72ac150d-501e-0090-392e-53e0ac000000", + "Content-Type" : "application/octet-stream", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:31:37 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:31:39 GMT", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:31:36 GMT", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-client-request-id" : "286f7a1b-101d-49b7-a905-73241cd65fc6" + }, + "Exception" : null + } ], + "variables" : [ "0d73644400d7364443cc83999b6206e8df4f64657b82", "0d73644410d7364443cc189079debf198110c435eaca", "0d73644420d7364443cc62709f00d9176b9494fa1a48", "2021-05-27T19:31:37.959028Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlockBlobUpload.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlockBlobUpload.json new file mode 100644 index 0000000000000..2e444f4db97e1 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestBlockBlobUpload.json @@ -0,0 +1,114 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/9f11288f09f11288ffcc2964735412cd5a1ba47af87b?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "d62f00aa-13c8-41ea-91da-7f71d951ab93" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D921460F3B6E3A", + "Last-Modified" : "Thu, 27 May 2021 19:31:43 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac1a5e-501e-0090-0c2e-53e0ac000000", + "x-ms-client-request-id" : "d62f00aa-13c8-41ea-91da-7f71d951ab93", + "Date" : "Thu, 27 May 2021 19:31:42 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/9f11288f19f11288ffcc70202f4c27a8223cd482fa5f/9f11288f29f11288ffcc68929653e8cf5354a45c29ee", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "30b575a6-188c-435f-825d-5e9ab412b413", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:44 GMT", + "x-ms-version-id" : "2021-05-27T19:31:44.3222203Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:43 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D921460FA03ABB", + "x-ms-request-id" : "72ac1ade-501e-0090-712e-53e0ac000000", + "x-ms-client-request-id" : "30b575a6-188c-435f-825d-5e9ab412b413" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/9f11288f19f11288ffcc70202f4c27a8223cd482fa5f/9f11288f29f11288ffcc68929653e8cf5354a45c29ee", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "0883c007-5696-44f5-8e08-c573de3d327f", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "6RYQPwaVsyQ=", + "Last-Modified" : "Thu, 27 May 2021 19:31:44 GMT", + "x-ms-version-id" : "2021-05-27T19:31:44.4142842Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:43 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "eTag" : "0x8D921460FAE1FEA", + "x-ms-request-id" : "72ac1af8-501e-0090-042e-53e0ac000000", + "x-ms-client-request-id" : "0883c007-5696-44f5-8e08-c573de3d327f" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/9f11288f19f11288ffcc70202f4c27a8223cd482fa5f/9f11288f29f11288ffcc68929653e8cf5354a45c29ee", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "819965ff-ac5b-4b80-a1c7-50a7f085ef51" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "7", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:31:44 GMT", + "x-ms-version-id" : "2021-05-27T19:31:44.4142842Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-blob-type" : "BlockBlob", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:44 GMT", + "eTag" : "0x8D921460FAE1FEA", + "x-ms-request-id" : "72ac1b16-501e-0090-182e-53e0ac000000", + "Content-Type" : "application/octet-stream", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:31:44 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:31:47 GMT", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:31:43 GMT", + "Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-client-request-id" : "819965ff-ac5b-4b80-a1c7-50a7f085ef51" + }, + "Exception" : null + } ], + "variables" : [ "9f11288f09f11288ffcc2964735412cd5a1ba47af87b", "9f11288f19f11288ffcc70202f4c27a8223cd482fa5f", "9f11288f29f11288ffcc68929653e8cf5354a45c29ee", "2021-05-27T19:31:45.236012400Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestContainerProperties.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestContainerProperties.json new file mode 100644 index 0000000000000..55d82875b5d4c --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestContainerProperties.json @@ -0,0 +1,100 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/20b1648e020b1648e0e51941938b0cb5d545641ecad0?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "57c425db-f35b-40fc-9318-c5f44f57f6b4" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F3FE0F7F", + "Last-Modified" : "Thu, 27 May 2021 19:30:57 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae7a29-a01e-002d-112e-5369b1000000", + "x-ms-client-request-id" : "57c425db-f35b-40fc-9318-c5f44f57f6b4", + "Date" : "Thu, 27 May 2021 19:30:57 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/20b1648e120b1648e0e5212131bc817ec08f4408ab64/20b1648e220b1648e0e547157668c96682a7944929f7", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "1b9423f9-9a05-439c-946e-2572fcdf2900", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:58 GMT", + "x-ms-version-id" : "2021-05-27T19:30:58.6177449Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:58 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145F46247A9", + "x-ms-request-id" : "6fae7aaa-a01e-002d-732e-5369b1000000", + "x-ms-client-request-id" : "1b9423f9-9a05-439c-946e-2572fcdf2900" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net/20b1648e120b1648e0e5212131bc817ec08f4408ab64?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "46ae6777-d646-42ff-ad02-5dc0497b4b79" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "x-ms-immutable-storage-with-versioning-enabled" : "true", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "x-ms-deny-encryption-scope-override" : "false", + "Last-Modified" : "Thu, 27 May 2021 19:30:58 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-has-legal-hold" : "false", + "Date" : "Thu, 27 May 2021 19:30:58 GMT", + "x-ms-default-encryption-scope" : "$account-encryption-key", + "x-ms-has-immutability-policy" : "false", + "eTag" : "0x8D92145F450C477", + "x-ms-request-id" : "6fae7abf-a01e-002d-052e-5369b1000000", + "x-ms-client-request-id" : "46ae6777-d646-42ff-ad02-5dc0497b4b79" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net?comp=list&prefix=20b1648e120b1648e0e5212131bc817ec08f4408ab64", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "a567e7b0-f46f-4c3d-abad-f824d542f789" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae7aca-a01e-002d-0e2e-5369b1000000", + "Body" : "20b1648e120b1648e0e5212131bc817ec08f4408ab6420b1648e120b1648e0e5212131bc817ec08f4408ab64Thu, 27 May 2021 19:30:58 GMT\"0x8D92145F450C477\"unlockedavailable$account-encryption-keyfalsefalsefalsetrue", + "x-ms-client-request-id" : "a567e7b0-f46f-4c3d-abad-f824d542f789", + "Date" : "Thu, 27 May 2021 19:30:58 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "20b1648e020b1648e0e51941938b0cb5d545641ecad0", "20b1648e120b1648e0e5212131bc817ec08f4408ab64", "20b1648e220b1648e0e547157668c96682a7944929f7" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestContainerSas.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestContainerSas.json new file mode 100644 index 0000000000000..c5122dc94d010 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestContainerSas.json @@ -0,0 +1,92 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/5fca972505fca97256f966501f3191159df764d70b76?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "7d441442-8beb-4908-ac46-91c0b1ab07f4" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D921462184317A", + "Last-Modified" : "Thu, 27 May 2021 19:32:14 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac36ba-501e-0090-3a2e-53e0ac000000", + "x-ms-client-request-id" : "7d441442-8beb-4908-ac46-91c0b1ab07f4", + "Date" : "Thu, 27 May 2021 19:32:13 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/5fca972515fca97256f915961d0f67ae1cfe3486a81f/5fca972525fca97256f955912e6f2cb59b63646b2815", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "5fbdd76f-4232-4e6c-9485-cf656cb184a3", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:32:14 GMT", + "x-ms-version-id" : "2021-05-27T19:32:14.8829329Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:32:14 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D9214621D76C91", + "x-ms-request-id" : "72ac3712-501e-0090-012e-53e0ac000000", + "x-ms-client-request-id" : "5fbdd76f-4232-4e6c-9485-cf656cb184a3" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/5fca972515fca97256f915961d0f67ae1cfe3486a81f/5fca972525fca97256f955912e6f2cb59b63646b2815?comp=immutabilityPolicies&sv=2020-10-02&se=2021-05-28T19%3A32%3A15Z&sr=c&sp=racwdxltmei&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "6665cf74-1072-4fef-9129-0b203e7c671b" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:32:17 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "72ac3723-501e-0090-0e2e-53e0ac000000", + "x-ms-client-request-id" : "6665cf74-1072-4fef-9129-0b203e7c671b", + "Date" : "Thu, 27 May 2021 19:32:14 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/5fca972515fca97256f915961d0f67ae1cfe3486a81f/5fca972525fca97256f955912e6f2cb59b63646b2815?comp=legalhold&sv=2020-10-02&se=2021-05-28T19%3A32%3A15Z&sr=c&sp=racwdxltmei&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "38eebf60-b5a1-40d6-ac2b-cf4e3f78395c" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "false", + "x-ms-request-id" : "72ac3731-501e-0090-182e-53e0ac000000", + "x-ms-client-request-id" : "38eebf60-b5a1-40d6-ac2b-cf4e3f78395c", + "Date" : "Thu, 27 May 2021 19:32:14 GMT" + }, + "Exception" : null + } ], + "variables" : [ "5fca972505fca97256f966501f3191159df764d70b76", "5fca972515fca97256f915961d0f67ae1cfe3486a81f", "5fca972525fca97256f955912e6f2cb59b63646b2815", "2021-05-27T19:32:15.796732500Z", "2021-05-27T19:32:15.821731300Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestCopy.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestCopy.json new file mode 100644 index 0000000000000..507ff6cf975fd --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestCopy.json @@ -0,0 +1,159 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d59f871e0d59f871e88608595bb07ab5ca34e44d4910?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "6d5abcf6-cf68-4137-a843-7aa00c3bacc3" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92146187753A0", + "Last-Modified" : "Thu, 27 May 2021 19:31:59 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac2912-501e-0090-122e-53e0ac000000", + "x-ms-client-request-id" : "6d5abcf6-cf68-4137-a843-7aa00c3bacc3", + "Date" : "Thu, 27 May 2021 19:31:58 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d59f871e1d59f871e88696273b789283c9d274fe7bab/d59f871e2d59f871e88601602ae6e26821b264666bd9", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "c4e88e99-e92f-4085-a757-b55ac1c28135", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-version-id" : "2021-05-27T19:31:59.6961403Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:58 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D9214618CA1A7B", + "x-ms-request-id" : "72ac2980-501e-0090-6c2e-53e0ac000000", + "x-ms-client-request-id" : "c4e88e99-e92f-4085-a757-b55ac1c28135" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d59f871e1d59f871e88696273b789283c9d274fe7bab/d59f871e3d59f871e88613392aa9c0a46bba6488e82d", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "94ace7ed-38a2-4f92-8206-faa844f601b7" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-copy-id" : "d83afc8e-7ba5-4311-8a8b-289ae8c96b7d", + "Last-Modified" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-version-id" : "2021-05-27T19:31:59.8962822Z", + "retry-after" : "0", + "StatusCode" : "202", + "Date" : "Thu, 27 May 2021 19:31:59 GMT", + "eTag" : "0x8D9214618E87D6E", + "x-ms-copy-status" : "success", + "x-ms-request-id" : "72ac29a4-501e-0090-082e-53e0ac000000", + "x-ms-client-request-id" : "94ace7ed-38a2-4f92-8206-faa844f601b7" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/d59f871e1d59f871e88696273b789283c9d274fe7bab/d59f871e3d59f871e88613392aa9c0a46bba6488e82d", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "b837b62e-3d75-440b-8158-bcf858a9c643" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-version-id" : "2021-05-27T19:31:59.8962822Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-blob-type" : "BlockBlob", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:59 GMT", + "eTag" : "0x8D9214618E87D6E", + "x-ms-request-id" : "72ac2aa1-501e-0090-5d2e-53e0ac000000", + "Content-Type" : "application/octet-stream", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-copy-id" : "d83afc8e-7ba5-4311-8a8b-289ae8c96b7d", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:32:02 GMT", + "x-ms-copy-source" : "https://seanmcccanary3.blob.core.windows.net/d59f871e1d59f871e88696273b789283c9d274fe7bab/d59f871e2d59f871e88601602ae6e26821b264666bd9", + "x-ms-copy-progress" : "0/0", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:32:00 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "Accept-Ranges" : "bytes", + "x-ms-copy-completion-time" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-server-encrypted" : "true", + "x-ms-copy-status" : "success", + "x-ms-client-request-id" : "b837b62e-3d75-440b-8158-bcf858a9c643" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/d59f871e1d59f871e88696273b789283c9d274fe7bab/d59f871e3d59f871e88613392aa9c0a46bba6488e82d", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e1919beb-65ab-412d-95b9-9c4e29dc85e4" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-version-id" : "2021-05-27T19:31:59.8962822Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-blob-type" : "BlockBlob", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:59 GMT", + "eTag" : "0x8D9214618E87D6E", + "x-ms-request-id" : "72ac2abf-501e-0090-752e-53e0ac000000", + "Content-Type" : "application/octet-stream", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-copy-id" : "d83afc8e-7ba5-4311-8a8b-289ae8c96b7d", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:32:02 GMT", + "x-ms-copy-source" : "https://seanmcccanary3.blob.core.windows.net/d59f871e1d59f871e88696273b789283c9d274fe7bab/d59f871e2d59f871e88601602ae6e26821b264666bd9", + "x-ms-copy-progress" : "0/0", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:32:00 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "Accept-Ranges" : "bytes", + "x-ms-copy-completion-time" : "Thu, 27 May 2021 19:31:59 GMT", + "x-ms-server-encrypted" : "true", + "x-ms-copy-status" : "success", + "x-ms-client-request-id" : "e1919beb-65ab-412d-95b9-9c4e29dc85e4" + }, + "Exception" : null + } ], + "variables" : [ "d59f871e0d59f871e88608595bb07ab5ca34e44d4910", "d59f871e1d59f871e88696273b789283c9d274fe7bab", "d59f871e2d59f871e88601602ae6e26821b264666bd9", "d59f871e3d59f871e88613392aa9c0a46bba6488e82d", "2021-05-27T19:32:00.613943300Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicy.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicy.json new file mode 100644 index 0000000000000..5efd5e3fb636f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicy.json @@ -0,0 +1,125 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a91327200a91327207cd77478567fec3cf8b84f6284b?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "29a6c8b9-9c0c-4fa9-868e-bd9c385bb88a" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145EB885EFD", + "Last-Modified" : "Thu, 27 May 2021 19:30:43 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae6e71-a01e-002d-7e2e-5369b1000000", + "x-ms-client-request-id" : "29a6c8b9-9c0c-4fa9-868e-bd9c385bb88a", + "Date" : "Thu, 27 May 2021 19:30:43 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a91327201a91327207cd30720211e6ee9c333400d814/a91327202a91327207cd0421834d4f021930a4665a0f", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "96e0ec08-c245-43df-9a1e-9658df3e0134", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:44 GMT", + "x-ms-version-id" : "2021-05-27T19:30:44.4116548Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:44 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145EBEA9A44", + "x-ms-request-id" : "6fae6f21-a01e-002d-112e-5369b1000000", + "x-ms-client-request-id" : "96e0ec08-c245-43df-9a1e-9658df3e0134" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a91327201a91327207cd30720211e6ee9c333400d814/a91327202a91327207cd0421834d4f021930a4665a0f?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "038a3860-d6d1-4944-882e-39f18eb6a962" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:47 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae6f2f-a01e-002d-1e2e-5369b1000000", + "x-ms-client-request-id" : "038a3860-d6d1-4944-882e-39f18eb6a962", + "Date" : "Thu, 27 May 2021 19:30:44 GMT" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://REDACTED.blob.core.windows.net/a91327201a91327207cd30720211e6ee9c333400d814/a91327202a91327207cd0421834d4f021930a4665a0f?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "190a6aba-4e42-4d6b-a61e-b00ba1fa27eb" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae6f3d-a01e-002d-292e-5369b1000000", + "x-ms-client-request-id" : "190a6aba-4e42-4d6b-a61e-b00ba1fa27eb", + "Date" : "Thu, 27 May 2021 19:30:44 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/a91327201a91327207cd30720211e6ee9c333400d814/a91327202a91327207cd0421834d4f021930a4665a0f", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "251d8eaa-9f95-48f5-946d-1c7984e84a8b" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:30:44 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:30:44 GMT", + "x-ms-version-id" : "2021-05-27T19:30:44.4116548Z", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Thu, 27 May 2021 19:30:44 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "x-ms-blob-type" : "BlockBlob", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:30:44 GMT", + "eTag" : "0x8D92145EBEA9A44", + "x-ms-request-id" : "6fae6f48-a01e-002d-332e-5369b1000000", + "x-ms-client-request-id" : "251d8eaa-9f95-48f5-946d-1c7984e84a8b", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + } ], + "variables" : [ "a91327200a91327207cd77478567fec3cf8b84f6284b", "a91327201a91327207cd30720211e6ee9c333400d814", "a91327202a91327207cd0421834d4f021930a4665a0f", "2021-05-27T19:30:45.334388200Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicyError.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicyError.json new file mode 100644 index 0000000000000..bae1619875c28 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicyError.json @@ -0,0 +1,73 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/019d317f0019d317f610559030c97ae3c06864cdd9ca?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "4f82ab18-b1aa-475f-8803-cbdca0c00901" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145ECC07B68", + "Last-Modified" : "Thu, 27 May 2021 19:30:45 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae702a-a01e-002d-6f2e-5369b1000000", + "x-ms-client-request-id" : "4f82ab18-b1aa-475f-8803-cbdca0c00901", + "Date" : "Thu, 27 May 2021 19:30:45 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/019d317f1019d317f61063016d580a9a5a85641e29b9/019d317f2019d317f61027136e56c9fb3df5444f8960", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "44ff3b0e-e434-4b58-afb4-d792bb4560f9", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:46 GMT", + "x-ms-version-id" : "2021-05-27T19:30:46.3440281Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:46 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145ED117599", + "x-ms-request-id" : "6fae70a1-a01e-002d-542e-5369b1000000", + "x-ms-client-request-id" : "44ff3b0e-e434-4b58-afb4-d792bb4560f9" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://REDACTED.blob.core.windows.net/019d317f1019d317f61063016d580a9a5a85641e29b9/019d317f3019d317f61082993145c90efd94440dc838?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "214788a5-049e-4c94-8f76-6880dc758ee4" + }, + "Response" : { + "content-length" : "216", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "BlobNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "6fae70b0-a01e-002d-622e-5369b1000000", + "Body" : "\nBlobNotFoundThe specified blob does not exist.\nRequestId:6fae70b0-a01e-002d-622e-5369b1000000\nTime:2021-05-27T19:30:46.4107590Z", + "x-ms-client-request-id" : "214788a5-049e-4c94-8f76-6880dc758ee4", + "Date" : "Thu, 27 May 2021 19:30:46 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "019d317f0019d317f610559030c97ae3c06864cdd9ca", "019d317f1019d317f61063016d580a9a5a85641e29b9", "019d317f2019d317f61027136e56c9fb3df5444f8960", "019d317f3019d317f61082993145c90efd94440dc838" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicyMin.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicyMin.json new file mode 100644 index 0000000000000..984c4813b5ec6 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestDeleteImmutabilityPolicyMin.json @@ -0,0 +1,125 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/ff00eec20ff00eec27c31594172217a1edd3f425f841?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "65ba2212-eda3-4753-b67f-b540afd59fd5" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145EA61D1F8", + "Last-Modified" : "Thu, 27 May 2021 19:30:41 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae6cb2-a01e-002d-082e-5369b1000000", + "x-ms-client-request-id" : "65ba2212-eda3-4753-b67f-b540afd59fd5", + "Date" : "Thu, 27 May 2021 19:30:41 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/ff00eec21ff00eec27c302490adb0e220ce704e93bc1/ff00eec22ff00eec27c3036410d75f25eedcd4dbca52", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "de8b4a72-7826-4b41-a79f-ad60c415c867", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:42 GMT", + "x-ms-version-id" : "2021-05-27T19:30:42.4432559Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:42 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145EABE3FAF", + "x-ms-request-id" : "6fae6d44-a01e-002d-7f2e-5369b1000000", + "x-ms-client-request-id" : "de8b4a72-7826-4b41-a79f-ad60c415c867" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/ff00eec21ff00eec27c302490adb0e220ce704e93bc1/ff00eec22ff00eec27c3036410d75f25eedcd4dbca52?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "bdf3c0e8-aea6-49ec-beee-2725a49b9fad" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:45 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae6d60-a01e-002d-172e-5369b1000000", + "x-ms-client-request-id" : "bdf3c0e8-aea6-49ec-beee-2725a49b9fad", + "Date" : "Thu, 27 May 2021 19:30:42 GMT" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://REDACTED.blob.core.windows.net/ff00eec21ff00eec27c302490adb0e220ce704e93bc1/ff00eec22ff00eec27c3036410d75f25eedcd4dbca52?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "c15d53c1-718a-4bc2-87b0-f37840b8939d" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae6d68-a01e-002d-1f2e-5369b1000000", + "x-ms-client-request-id" : "c15d53c1-718a-4bc2-87b0-f37840b8939d", + "Date" : "Thu, 27 May 2021 19:30:42 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/ff00eec21ff00eec27c302490adb0e220ce704e93bc1/ff00eec22ff00eec27c3036410d75f25eedcd4dbca52", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "5e44acd0-a70c-4018-ac8c-d3c934bf75ed" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:30:42 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:30:42 GMT", + "x-ms-version-id" : "2021-05-27T19:30:42.4432559Z", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Thu, 27 May 2021 19:30:42 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "x-ms-blob-type" : "BlockBlob", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:30:42 GMT", + "eTag" : "0x8D92145EABE3FAF", + "x-ms-request-id" : "6fae6d80-a01e-002d-2e2e-5369b1000000", + "x-ms-client-request-id" : "5e44acd0-a70c-4018-ac8c-d3c934bf75ed", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + } ], + "variables" : [ "ff00eec20ff00eec27c31594172217a1edd3f425f841", "ff00eec21ff00eec27c302490adb0e220ce704e93bc1", "ff00eec22ff00eec27c3036410d75f25eedcd4dbca52", "2021-05-27T19:30:43.365659Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestPageBlobCreate.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestPageBlobCreate.json new file mode 100644 index 0000000000000..519ac639e70b9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestPageBlobCreate.json @@ -0,0 +1,108 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/e79977f40e79977f423d6785597fedba291924093a19?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "79449c3c-afa2-4904-85ba-72981c71350e" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F96380CC", + "Last-Modified" : "Thu, 27 May 2021 19:31:07 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae8143-a01e-002d-5e2e-5369b1000000", + "x-ms-client-request-id" : "79449c3c-afa2-4904-85ba-72981c71350e", + "Date" : "Thu, 27 May 2021 19:31:06 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/e79977f41e79977f423d86256c0e10cae126a4129a7c/e79977f42e79977f423d9924652e03092df4d4969b56", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "317fd6a0-b0d4-40bf-9511-39642b46b67c", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:29 GMT", + "x-ms-version-id" : "2021-05-27T19:31:29.4246329Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:28 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D9214606BF09B9", + "x-ms-request-id" : "72ac0cbc-501e-0090-592e-53e0ac000000", + "x-ms-client-request-id" : "317fd6a0-b0d4-40bf-9511-39642b46b67c" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/e79977f41e79977f423d86256c0e10cae126a4129a7c/e79977f43e79977f423d5483050fb3a9c06d547e19d1", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "dca4eff8-8cde-427d-a1f2-eed801fd1d60" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D9214606E16509", + "Last-Modified" : "Thu, 27 May 2021 19:31:29 GMT", + "x-ms-version-id" : "2021-05-27T19:31:29.6497929Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac0d0c-501e-0090-1e2e-53e0ac000000", + "x-ms-request-server-encrypted" : "true", + "x-ms-client-request-id" : "dca4eff8-8cde-427d-a1f2-eed801fd1d60", + "Date" : "Thu, 27 May 2021 19:31:28 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/e79977f41e79977f423d86256c0e10cae126a4129a7c/e79977f43e79977f423d5483050fb3a9c06d547e19d1", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e8422a80-b2ad-428d-a945-169b5e0226a9" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "512", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:31:32 GMT", + "x-ms-lease-state" : "available", + "x-ms-blob-sequence-number" : "0", + "Last-Modified" : "Thu, 27 May 2021 19:31:29 GMT", + "x-ms-version-id" : "2021-05-27T19:31:29.6497929Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:31:29 GMT", + "x-ms-blob-type" : "PageBlob", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:29 GMT", + "eTag" : "0x8D9214606E16509", + "x-ms-request-id" : "72ac0d29-501e-0090-3b2e-53e0ac000000", + "x-ms-client-request-id" : "e8422a80-b2ad-428d-a945-169b5e0226a9", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + } ], + "variables" : [ "e79977f40e79977f423d6785597fedba291924093a19", "e79977f41e79977f423d86256c0e10cae126a4129a7c", "e79977f42e79977f423d9924652e03092df4d4969b56", "e79977f43e79977f423d5483050fb3a9c06d547e19d1", "2021-05-27T19:31:30.367948100Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyACFail.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyACFail.json new file mode 100644 index 0000000000000..24d0aedb711f7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyACFail.json @@ -0,0 +1,73 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/6f9714f106f9714f1e2e9999704236d02bf43499183d?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e9fd5d16-5f2d-4a65-976c-275e26a1ea9c" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145E703648C", + "Last-Modified" : "Thu, 27 May 2021 19:30:36 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae67af-a01e-002d-522e-5369b1000000", + "x-ms-client-request-id" : "e9fd5d16-5f2d-4a65-976c-275e26a1ea9c", + "Date" : "Thu, 27 May 2021 19:30:35 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/6f9714f116f9714f1e2e0906934f0e7cc2c6c41a2b61/6f9714f126f9714f1e2e723114916c5b2201b4df4a6f", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "41ae27b1-860b-41e5-8ecd-5297e3b64ee3", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:36 GMT", + "x-ms-version-id" : "2021-05-27T19:30:36.7472078Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:36 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145E758F2AF", + "x-ms-request-id" : "6fae6817-a01e-002d-2d2e-5369b1000000", + "x-ms-client-request-id" : "41ae27b1-860b-41e5-8ecd-5297e3b64ee3" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/6f9714f116f9714f1e2e0906934f0e7cc2c6c41a2b61/6f9714f126f9714f1e2e723114916c5b2201b4df4a6f?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e6a10127-1132-4def-8694-9ce96d7dab27" + }, + "Response" : { + "content-length" : "253", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "ConditionNotMet", + "retry-after" : "0", + "StatusCode" : "412", + "x-ms-request-id" : "6fae6821-a01e-002d-372e-5369b1000000", + "Body" : "\nConditionNotMetThe condition specified using HTTP conditional header(s) is not met.\nRequestId:6fae6821-a01e-002d-372e-5369b1000000\nTime:2021-05-27T19:30:36.8249644Z", + "x-ms-client-request-id" : "e6a10127-1132-4def-8694-9ce96d7dab27", + "Date" : "Thu, 27 May 2021 19:30:36 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "6f9714f106f9714f1e2e9999704236d02bf43499183d", "6f9714f116f9714f1e2e0906934f0e7cc2c6c41a2b61", "6f9714f126f9714f1e2e723114916c5b2201b4df4a6f", "2021-05-27T19:30:37.668717700Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyAC[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyAC[0].json new file mode 100644 index 0000000000000..742ec187a1c32 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyAC[0].json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/bee3c81f0bee3c81ff0476185073e89b6dea64827bd3?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "999d1dc6-fe46-4928-b584-da364bf50768" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145DE955648", + "Last-Modified" : "Thu, 27 May 2021 19:30:22 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae5b79-a01e-002d-372e-5369b1000000", + "x-ms-client-request-id" : "999d1dc6-fe46-4928-b584-da364bf50768", + "Date" : "Thu, 27 May 2021 19:30:21 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/bee3c81f1bee3c81ff0410058d394bf05f8024576b5a/bee3c81f2bee3c81ff04014883c8f6729bd2b425991b", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "dec599d6-9239-4389-a6b4-c34b6c57d000", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:22 GMT", + "x-ms-version-id" : "2021-05-27T19:30:22.6531915Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:22 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145DEF2864B", + "x-ms-request-id" : "6fae5c0b-a01e-002d-322e-5369b1000000", + "x-ms-client-request-id" : "dec599d6-9239-4389-a6b4-c34b6c57d000" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/bee3c81f1bee3c81ff0410058d394bf05f8024576b5a/bee3c81f2bee3c81ff04014883c8f6729bd2b425991b?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "9d11a59e-aa68-498d-9033-70082d60d631" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:25 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae5c2a-a01e-002d-4d2e-5369b1000000", + "x-ms-client-request-id" : "9d11a59e-aa68-498d-9033-70082d60d631", + "Date" : "Thu, 27 May 2021 19:30:22 GMT" + }, + "Exception" : null + } ], + "variables" : [ "bee3c81f0bee3c81ff0476185073e89b6dea64827bd3", "bee3c81f1bee3c81ff0410058d394bf05f8024576b5a", "bee3c81f2bee3c81ff04014883c8f6729bd2b425991b", "2021-05-27T19:30:23.613626900Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyAC[1].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyAC[1].json new file mode 100644 index 0000000000000..526533ce86c12 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyAC[1].json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a7f8f95e0a7f8f95efad973804e834057ad6a49a58b7?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "928e8a2d-065a-4e58-8530-6f1a8a8df36d" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145E2BF9D61", + "Last-Modified" : "Thu, 27 May 2021 19:30:29 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae60f6-a01e-002d-2a2e-5369b1000000", + "x-ms-client-request-id" : "928e8a2d-065a-4e58-8530-6f1a8a8df36d", + "Date" : "Thu, 27 May 2021 19:30:28 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a7f8f95e1a7f8f95efad34142e396f162341742d3a6f/a7f8f95e2a7f8f95efad36451c059d6e8eb2a4740a3c", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "2966f37a-e9f1-457c-8612-b62fe42142fe", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:29 GMT", + "x-ms-version-id" : "2021-05-27T19:30:29.5961257Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:29 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145E315EEA9", + "x-ms-request-id" : "6fae6173-a01e-002d-132e-5369b1000000", + "x-ms-client-request-id" : "2966f37a-e9f1-457c-8612-b62fe42142fe" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a7f8f95e1a7f8f95efad34142e396f162341742d3a6f/a7f8f95e2a7f8f95efad36451c059d6e8eb2a4740a3c?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3ec0b61d-e687-4f61-b93a-5607ddd4064b" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:32 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae6184-a01e-002d-202e-5369b1000000", + "x-ms-client-request-id" : "3ec0b61d-e687-4f61-b93a-5607ddd4064b", + "Date" : "Thu, 27 May 2021 19:30:29 GMT" + }, + "Exception" : null + } ], + "variables" : [ "a7f8f95e0a7f8f95efad973804e834057ad6a49a58b7", "a7f8f95e1a7f8f95efad34142e396f162341742d3a6f", "a7f8f95e2a7f8f95efad36451c059d6e8eb2a4740a3c", "2021-05-27T19:30:30.518837300Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyError.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyError.json new file mode 100644 index 0000000000000..c464ae2209b92 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyError.json @@ -0,0 +1,73 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a29af0b60a29af0b6342749099d4bec3197634b878b7?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "f34a7aab-716b-44ae-8135-b09b7d4153aa" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145E840B203", + "Last-Modified" : "Thu, 27 May 2021 19:30:38 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae6960-a01e-002d-3a2e-5369b1000000", + "x-ms-client-request-id" : "f34a7aab-716b-44ae-8135-b09b7d4153aa", + "Date" : "Thu, 27 May 2021 19:30:37 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a29af0b61a29af0b634299937f377e27a4f294fd0b9c/a29af0b62a29af0b63426959523d1951d13cf47afb0e", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "8287997f-3ebd-4371-8c08-b46864a1a021", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:38 GMT", + "x-ms-version-id" : "2021-05-27T19:30:38.8637116Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:38 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145E89BE6A9", + "x-ms-request-id" : "6fae69eb-a01e-002d-342e-5369b1000000", + "x-ms-client-request-id" : "8287997f-3ebd-4371-8c08-b46864a1a021" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/a29af0b61a29af0b634299937f377e27a4f294fd0b9c/a29af0b63a29af0b634256958026593c9b7164dbfa11?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "adcceb4b-0d34-4851-9086-e4ecde64dee7" + }, + "Response" : { + "content-length" : "216", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "BlobNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "6fae6a07-a01e-002d-4b2e-5369b1000000", + "Body" : "\nBlobNotFoundThe specified blob does not exist.\nRequestId:6fae6a07-a01e-002d-4b2e-5369b1000000\nTime:2021-05-27T19:30:38.9424666Z", + "x-ms-client-request-id" : "adcceb4b-0d34-4851-9086-e4ecde64dee7", + "Date" : "Thu, 27 May 2021 19:30:38 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "a29af0b60a29af0b6342749099d4bec3197634b878b7", "a29af0b61a29af0b634299937f377e27a4f294fd0b9c", "a29af0b62a29af0b63426959523d1951d13cf47afb0e", "a29af0b63a29af0b634256958026593c9b7164dbfa11", "2021-05-27T19:30:39.786663Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyIA.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyIA.json new file mode 100644 index 0000000000000..7a4212fed072b --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyIA.json @@ -0,0 +1,51 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/1194909e01194909ea1801848275ac675a531443dbb8?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "cbda0cdc-af4d-4407-8c38-2cace594aed8" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145E950574C", + "Last-Modified" : "Thu, 27 May 2021 19:30:40 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae6b02-a01e-002d-272e-5369b1000000", + "x-ms-client-request-id" : "cbda0cdc-af4d-4407-8c38-2cace594aed8", + "Date" : "Thu, 27 May 2021 19:30:39 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/1194909e11194909ea1883281460da4c7491949879d6/1194909e21194909ea185473504fa080b36824d868ad", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "790cbe6f-26bb-4a7c-90d6-5df60cfad855", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:40 GMT", + "x-ms-version-id" : "2021-05-27T19:30:40.6599886Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:40 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145E9AE24CE", + "x-ms-request-id" : "6fae6bb5-a01e-002d-392e-5369b1000000", + "x-ms-client-request-id" : "790cbe6f-26bb-4a7c-90d6-5df60cfad855" + }, + "Exception" : null + } ], + "variables" : [ "1194909e01194909ea1801848275ac675a531443dbb8", "1194909e11194909ea1883281460da4c7491949879d6", "1194909e21194909ea185473504fa080b36824d868ad", "2021-05-27T19:30:41.579827500Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyMin.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyMin.json new file mode 100644 index 0000000000000..a9b3277abe50f --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicyMin.json @@ -0,0 +1,72 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/35fa8f77035fa8f77f044077222823529fb0140f78fe?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3768d026-b423-4436-b6c2-bc8bbbd90719" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145D4BE00CD", + "Last-Modified" : "Thu, 27 May 2021 19:30:05 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae4a60-a01e-002d-1c2e-5369b1000000", + "x-ms-client-request-id" : "3768d026-b423-4436-b6c2-bc8bbbd90719", + "Date" : "Thu, 27 May 2021 19:30:05 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/35fa8f77135fa8f77f04064142f07614b9904485fac2/35fa8f77235fa8f77f0442672aea10378e9a34819835", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "bddb632e-0eb2-473a-addf-60e40e00b27e", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:07 GMT", + "x-ms-version-id" : "2021-05-27T19:30:07.9797693Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:07 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145D63389BD", + "x-ms-request-id" : "6fae4cd8-a01e-002d-292e-5369b1000000", + "x-ms-client-request-id" : "bddb632e-0eb2-473a-addf-60e40e00b27e" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/35fa8f77135fa8f77f04064142f07614b9904485fac2/35fa8f77235fa8f77f0442672aea10378e9a34819835?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "db913330-eebb-43d3-955b-c537abda4cae" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:10 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae4cfe-a01e-002d-472e-5369b1000000", + "x-ms-client-request-id" : "db913330-eebb-43d3-955b-c537abda4cae", + "Date" : "Thu, 27 May 2021 19:30:07 GMT" + }, + "Exception" : null + } ], + "variables" : [ "35fa8f77035fa8f77f044077222823529fb0140f78fe", "35fa8f77135fa8f77f04064142f07614b9904485fac2", "35fa8f77235fa8f77f0442672aea10378e9a34819835", "2021-05-27T19:30:08.925445400Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicy[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicy[0].json new file mode 100644 index 0000000000000..adf9b01c01286 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetImmutabilityPolicy[0].json @@ -0,0 +1,129 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/f9f8d7be0f9f8d7be03c35094f9e47268a06d484bbc1?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "785132cb-0f3b-4e63-a987-07a4c78c4460" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145DA564B2E", + "Last-Modified" : "Thu, 27 May 2021 19:30:14 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae5479-a01e-002d-712e-5369b1000000", + "x-ms-client-request-id" : "785132cb-0f3b-4e63-a987-07a4c78c4460", + "Date" : "Thu, 27 May 2021 19:30:14 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/f9f8d7be1f9f8d7be03c75436721de7444a2d44e28ba/f9f8d7be2f9f8d7be03c9162320d9e24b68624109898", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "68d448d5-f1e6-45d9-8065-5392f4d707ef", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:15 GMT", + "x-ms-version-id" : "2021-05-27T19:30:15.4750957Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:15 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145DAAB3BED", + "x-ms-request-id" : "6fae5532-a01e-002d-062e-5369b1000000", + "x-ms-client-request-id" : "68d448d5-f1e6-45d9-8065-5392f4d707ef" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/f9f8d7be1f9f8d7be03c75436721de7444a2d44e28ba/f9f8d7be2f9f8d7be03c9162320d9e24b68624109898?comp=immutabilityPolicies", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "14983565-5eda-4e3f-9f6e-41fad056c1e1" + }, + "Response" : { + "content-length" : "0", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:18 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae5544-a01e-002d-142e-5369b1000000", + "x-ms-client-request-id" : "14983565-5eda-4e3f-9f6e-41fad056c1e1", + "Date" : "Thu, 27 May 2021 19:30:15 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/f9f8d7be1f9f8d7be03c75436721de7444a2d44e28ba/f9f8d7be2f9f8d7be03c9162320d9e24b68624109898", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "ca09735e-c5db-4664-bc78-f4ce623f83dc" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:30:15 GMT", + "x-ms-version-id" : "2021-05-27T19:30:15.4750957Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-blob-type" : "BlockBlob", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:30:15 GMT", + "eTag" : "0x8D92145DAAB3BED", + "x-ms-request-id" : "6fae556f-a01e-002d-322e-5369b1000000", + "Content-Type" : "application/octet-stream", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:30:15 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:30:18 GMT", + "Date" : "Thu, 27 May 2021 19:30:15 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-client-request-id" : "ca09735e-c5db-4664-bc78-f4ce623f83dc" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net/f9f8d7be1f9f8d7be03c75436721de7444a2d44e28ba?restype=container&comp=list&include=immutabilitypolicy%2Clegalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "bad06dd6-7d1d-490c-bc84-9e2050bb3202" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae5584-a01e-002d-452e-5369b1000000", + "Body" : "f9f8d7be2f9f8d7be03c9162320d9e24b686241098982021-05-27T19:30:15.4750957ZtrueThu, 27 May 2021 19:30:15 GMTThu, 27 May 2021 19:30:15 GMT0x8D92145DAAB3BED0application/octet-stream1B2M2Y8AsgTpgAmY7PhCfg==Thu, 27 May 2021 19:30:15 GMTBlockBlobHottrueunlockedavailabletrueThu, 27 May 2021 19:30:18 GMTunlocked", + "x-ms-client-request-id" : "bad06dd6-7d1d-490c-bc84-9e2050bb3202", + "Date" : "Thu, 27 May 2021 19:30:15 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "f9f8d7be0f9f8d7be03c35094f9e47268a06d484bbc1", "f9f8d7be1f9f8d7be03c75436721de7444a2d44e28ba", "f9f8d7be2f9f8d7be03c9162320d9e24b68624109898", "2021-05-27T19:30:16.401924500Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldError.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldError.json new file mode 100644 index 0000000000000..8cb53e99fb828 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldError.json @@ -0,0 +1,73 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/1cad1a8201cad1a8226d2748443d1e3edf0574ef6ad9?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "cdeebd59-c27f-4ca6-b9bd-b0a8845a809b" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F292F321", + "Last-Modified" : "Thu, 27 May 2021 19:30:55 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae7880-a01e-002d-272e-5369b1000000", + "x-ms-client-request-id" : "cdeebd59-c27f-4ca6-b9bd-b0a8845a809b", + "Date" : "Thu, 27 May 2021 19:30:55 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/1cad1a8211cad1a8226d34657002385c9d9044b90bc1/1cad1a8221cad1a8226d623027e8f1a55026d499fad6", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "0ed0f080-bb09-4a97-ab3b-229f0f671ec1", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:56 GMT", + "x-ms-version-id" : "2021-05-27T19:30:56.1499911Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:55 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145F2E9BB07", + "x-ms-request-id" : "6fae78e6-a01e-002d-012e-5369b1000000", + "x-ms-client-request-id" : "0ed0f080-bb09-4a97-ab3b-229f0f671ec1" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/1cad1a8211cad1a8226d34657002385c9d9044b90bc1/1cad1a8231cad1a8226d76925417631f1c7ae4db2876?comp=legalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "1444b24c-2d64-40be-8036-cc64a89345dc" + }, + "Response" : { + "content-length" : "216", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "BlobNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "6fae7900-a01e-002d-142e-5369b1000000", + "Body" : "\nBlobNotFoundThe specified blob does not exist.\nRequestId:6fae7900-a01e-002d-142e-5369b1000000\nTime:2021-05-27T19:30:56.2297226Z", + "x-ms-client-request-id" : "1444b24c-2d64-40be-8036-cc64a89345dc", + "Date" : "Thu, 27 May 2021 19:30:55 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "1cad1a8201cad1a8226d2748443d1e3edf0574ef6ad9", "1cad1a8211cad1a8226d34657002385c9d9044b90bc1", "1cad1a8221cad1a8226d623027e8f1a55026d499fad6", "1cad1a8231cad1a8226d76925417631f1c7ae4db2876" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldMin[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldMin[0].json new file mode 100644 index 0000000000000..eaa303ace91fb --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldMin[0].json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/c4f321c00c4f321c0c8a8530446859f65530e46fab2e?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e305fc7b-16b8-4603-bf3d-9f1a932d85c2" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145EDBA9934", + "Last-Modified" : "Thu, 27 May 2021 19:30:47 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae719e-a01e-002d-1d2e-5369b1000000", + "x-ms-client-request-id" : "e305fc7b-16b8-4603-bf3d-9f1a932d85c2", + "Date" : "Thu, 27 May 2021 19:30:47 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/c4f321c01c4f321c0c8a08080f64f872d2bca47d1a26/c4f321c02c4f321c0c8a32656154152657b384460beb", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "89ea3ee3-81d7-4386-b793-a3fac901cb45", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:48 GMT", + "x-ms-version-id" : "2021-05-27T19:30:48.0242222Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:47 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145EE11D62E", + "x-ms-request-id" : "6fae7207-a01e-002d-702e-5369b1000000", + "x-ms-client-request-id" : "89ea3ee3-81d7-4386-b793-a3fac901cb45" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/c4f321c01c4f321c0c8a08080f64f872d2bca47d1a26/c4f321c02c4f321c0c8a32656154152657b384460beb?comp=legalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "338e547a-bc9d-4235-9f67-b7f6d8ea2e34" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "true", + "x-ms-request-id" : "6fae723a-a01e-002d-162e-5369b1000000", + "x-ms-client-request-id" : "338e547a-bc9d-4235-9f67-b7f6d8ea2e34", + "Date" : "Thu, 27 May 2021 19:30:48 GMT" + }, + "Exception" : null + } ], + "variables" : [ "c4f321c00c4f321c0c8a8530446859f65530e46fab2e", "c4f321c01c4f321c0c8a08080f64f872d2bca47d1a26", "c4f321c02c4f321c0c8a32656154152657b384460beb" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldMin[1].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldMin[1].json new file mode 100644 index 0000000000000..dd130611a3214 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHoldMin[1].json @@ -0,0 +1,71 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/dde810810dde810814c564663cd263218ded24c53b70?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "fffe5fef-634c-4303-abf0-01e85fd92a59" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145EF0900CB", + "Last-Modified" : "Thu, 27 May 2021 19:30:49 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae735e-a01e-002d-032e-5369b1000000", + "x-ms-client-request-id" : "fffe5fef-634c-4303-abf0-01e85fd92a59", + "Date" : "Thu, 27 May 2021 19:30:49 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/dde810811dde810814c5748314d1a13006b394eeb8f2/dde810812dde810814c59645123276b064a5e4a0ab2c", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "0b1c1e1d-6caa-410d-8b44-e809e44a2e43", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:50 GMT", + "x-ms-version-id" : "2021-05-27T19:30:50.4499397Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:50 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145EF83D1B3", + "x-ms-request-id" : "6fae7417-a01e-002d-192e-5369b1000000", + "x-ms-client-request-id" : "0b1c1e1d-6caa-410d-8b44-e809e44a2e43" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/dde810811dde810814c5748314d1a13006b394eeb8f2/dde810812dde810814c59645123276b064a5e4a0ab2c?comp=legalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "669920e5-9740-4209-b702-46e82dee24d5" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "false", + "x-ms-request-id" : "6fae742b-a01e-002d-2b2e-5369b1000000", + "x-ms-client-request-id" : "669920e5-9740-4209-b702-46e82dee24d5", + "Date" : "Thu, 27 May 2021 19:30:50 GMT" + }, + "Exception" : null + } ], + "variables" : [ "dde810810dde810814c564663cd263218ded24c53b70", "dde810811dde810814c5748314d1a13006b394eeb8f2", "dde810812dde810814c59645123276b064a5e4a0ab2c" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHold[0].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHold[0].json new file mode 100644 index 0000000000000..6e87a4aba1d0d --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHold[0].json @@ -0,0 +1,127 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/0038749a00038749aa4e5464192f4d7266364456b990?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "306dbf9e-102d-43c8-aa22-120a58ab1ab7" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F0442B07", + "Last-Modified" : "Thu, 27 May 2021 19:30:51 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae7530-a01e-002d-7d2e-5369b1000000", + "x-ms-client-request-id" : "306dbf9e-102d-43c8-aa22-120a58ab1ab7", + "Date" : "Thu, 27 May 2021 19:30:51 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/0038749a10038749aa4e208526673b23e0591437b9ee/0038749a20038749aa4e175695cd9337dc9d6435087a", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "94061b0f-de3a-4384-8d33-e923edb9cd71", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:52 GMT", + "x-ms-version-id" : "2021-05-27T19:30:52.2692331Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:51 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145F09992EB", + "x-ms-request-id" : "6fae75bd-a01e-002d-6d2e-5369b1000000", + "x-ms-client-request-id" : "94061b0f-de3a-4384-8d33-e923edb9cd71" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/0038749a10038749aa4e208526673b23e0591437b9ee/0038749a20038749aa4e175695cd9337dc9d6435087a?comp=legalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "fd8d74a7-3c20-4aac-ad4a-b86d2d62cc12" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "true", + "x-ms-request-id" : "6fae75c8-a01e-002d-762e-5369b1000000", + "x-ms-client-request-id" : "fd8d74a7-3c20-4aac-ad4a-b86d2d62cc12", + "Date" : "Thu, 27 May 2021 19:30:52 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/0038749a10038749aa4e208526673b23e0591437b9ee/0038749a20038749aa4e175695cd9337dc9d6435087a", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3ff0f7ad-05e9-48dc-b67e-4cdaebcc95bf" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:30:52 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:30:52 GMT", + "x-ms-version-id" : "2021-05-27T19:30:52.2692331Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:30:52 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "x-ms-blob-type" : "BlockBlob", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:30:52 GMT", + "eTag" : "0x8D92145F09992EB", + "x-ms-request-id" : "6fae75d6-a01e-002d-012e-5369b1000000", + "x-ms-client-request-id" : "3ff0f7ad-05e9-48dc-b67e-4cdaebcc95bf", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net/0038749a10038749aa4e208526673b23e0591437b9ee?restype=container&comp=list&include=immutabilitypolicy%2Clegalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "b52e0c58-162a-4a3a-89c0-dee3f501e74f" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae75ed-a01e-002d-0f2e-5369b1000000", + "Body" : "0038749a20038749aa4e175695cd9337dc9d6435087a2021-05-27T19:30:52.2692331ZtrueThu, 27 May 2021 19:30:52 GMTThu, 27 May 2021 19:30:52 GMT0x8D92145F09992EB0application/octet-stream1B2M2Y8AsgTpgAmY7PhCfg==Thu, 27 May 2021 19:30:52 GMTBlockBlobHottrueunlockedavailabletruetrue", + "x-ms-client-request-id" : "b52e0c58-162a-4a3a-89c0-dee3f501e74f", + "Date" : "Thu, 27 May 2021 19:30:52 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "0038749a00038749aa4e5464192f4d7266364456b990", "0038749a10038749aa4e208526673b23e0591437b9ee", "0038749a20038749aa4e175695cd9337dc9d6435087a" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHold[1].json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHold[1].json new file mode 100644 index 0000000000000..cf6bbb4573496 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSetLegalHold[1].json @@ -0,0 +1,127 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/192345db0192345db76951814025818c3afb944e4802?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "3041533d-d404-4a18-b368-ec0164cf5990" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D92145F170D3B5", + "Last-Modified" : "Thu, 27 May 2021 19:30:53 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "6fae76ee-a01e-002d-5d2e-5369b1000000", + "x-ms-client-request-id" : "3041533d-d404-4a18-b368-ec0164cf5990", + "Date" : "Thu, 27 May 2021 19:30:53 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/192345db1192345db769129816c5586fdf56a48c7909/192345db2192345db76907154af2a6809768b449f80c", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "b4e7418e-16ac-4de7-8ddd-2a31e2580fb7", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:30:54 GMT", + "x-ms-version-id" : "2021-05-27T19:30:54.2296259Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:30:53 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D92145F1C4B4C3", + "x-ms-request-id" : "6fae7760-a01e-002d-382e-5369b1000000", + "x-ms-client-request-id" : "b4e7418e-16ac-4de7-8ddd-2a31e2580fb7" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/192345db1192345db769129816c5586fdf56a48c7909/192345db2192345db76907154af2a6809768b449f80c?comp=legalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "c7d5a4e3-ec19-4341-a643-cd6e64d6da72" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "false", + "x-ms-request-id" : "6fae7778-a01e-002d-4c2e-5369b1000000", + "x-ms-client-request-id" : "c7d5a4e3-ec19-4341-a643-cd6e64d6da72", + "Date" : "Thu, 27 May 2021 19:30:54 GMT" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/192345db1192345db769129816c5586fdf56a48c7909/192345db2192345db76907154af2a6809768b449f80c", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "ebefa5c1-b93a-4d37-9f44-c230caf8042d" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:30:54 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:30:54 GMT", + "x-ms-version-id" : "2021-05-27T19:30:54.2296259Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-legal-hold" : "false", + "Date" : "Thu, 27 May 2021 19:30:54 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "x-ms-blob-type" : "BlockBlob", + "Accept-Ranges" : "bytes", + "x-ms-server-encrypted" : "true", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:30:54 GMT", + "eTag" : "0x8D92145F1C4B4C3", + "x-ms-request-id" : "6fae778c-a01e-002d-5f2e-5369b1000000", + "x-ms-client-request-id" : "ebefa5c1-b93a-4d37-9f44-c230caf8042d", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net/192345db1192345db769129816c5586fdf56a48c7909?restype=container&comp=list&include=immutabilitypolicy%2Clegalhold", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "f1c3f117-7fd9-4957-adf7-fe85c8bdb5ec" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "6fae779a-a01e-002d-6a2e-5369b1000000", + "Body" : "192345db2192345db76907154af2a6809768b449f80c2021-05-27T19:30:54.2296259ZtrueThu, 27 May 2021 19:30:54 GMTThu, 27 May 2021 19:30:54 GMT0x8D92145F1C4B4C30application/octet-stream1B2M2Y8AsgTpgAmY7PhCfg==Thu, 27 May 2021 19:30:54 GMTBlockBlobHottrueunlockedavailabletruefalse", + "x-ms-client-request-id" : "f1c3f117-7fd9-4957-adf7-fe85c8bdb5ec", + "Date" : "Thu, 27 May 2021 19:30:54 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "192345db0192345db76951814025818c3afb944e4802", "192345db1192345db769129816c5586fdf56a48c7909", "192345db2192345db76907154af2a6809768b449f80c" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSyncCopy.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSyncCopy.json new file mode 100644 index 0000000000000..093fddff421ea --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ImmutableStorageWithVersioningTestSyncCopy.json @@ -0,0 +1,162 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d26dfd8c0d26dfd8c66c643965f9fa5d417fb493c876?restype=container", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "376d5c0b-053b-42e3-8872-7d157b517456" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D9214613929A8E", + "Last-Modified" : "Thu, 27 May 2021 19:31:50 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "72ac20e1-501e-0090-462e-53e0ac000000", + "x-ms-client-request-id" : "376d5c0b-053b-42e3-8872-7d157b517456", + "Date" : "Thu, 27 May 2021 19:31:50 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962/d26dfd8c2d26dfd8c66c056963ddec71061124ac0a65", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "0af9e98e-f497-41f6-b2ae-bdf05d9071d7", + "Content-Type" : "application/octet-stream" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:51 GMT", + "x-ms-version-id" : "2021-05-27T19:31:51.5923811Z", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Thu, 27 May 2021 19:31:50 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "eTag" : "0x8D9214613F59163", + "x-ms-request-id" : "72ac21b2-501e-0090-6d2e-53e0ac000000", + "x-ms-client-request-id" : "0af9e98e-f497-41f6-b2ae-bdf05d9071d7" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962?restype=container&comp=acl", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "fb0bfee0-8fbe-4c2d-8cfa-490d5c3076de", + "Content-Type" : "application/xml" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D9214614015612", + "Last-Modified" : "Thu, 27 May 2021 19:31:51 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "72ac21c2-501e-0090-7a2e-53e0ac000000", + "x-ms-client-request-id" : "fb0bfee0-8fbe-4c2d-8cfa-490d5c3076de", + "Date" : "Thu, 27 May 2021 19:31:50 GMT" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962/d26dfd8c3d26dfd8c66c5153743fb081fb0274d9199a", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "647fabee-69ee-4a41-8402-4df1d4a6d9dd" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-copy-id" : "11b3722b-93c1-4f73-a16e-15aab4bbc0ed", + "x-ms-content-crc64" : "AAAAAAAAAAA=", + "Last-Modified" : "Thu, 27 May 2021 19:31:51 GMT", + "x-ms-version-id" : "2021-05-27T19:31:52.5570663Z", + "retry-after" : "0", + "StatusCode" : "202", + "Date" : "Thu, 27 May 2021 19:31:51 GMT", + "eTag" : "0x8D92146141E7949", + "x-ms-copy-status" : "success", + "x-ms-request-id" : "72ac21d0-501e-0090-072e-53e0ac000000", + "x-ms-client-request-id" : "647fabee-69ee-4a41-8402-4df1d4a6d9dd" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://REDACTED.blob.core.windows.net/d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962/d26dfd8c3d26dfd8c66c5153743fb081fb0274d9199a", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "7eb58e7c-5c9b-4774-8a50-32adb6de31e0" + }, + "Response" : { + "x-ms-is-current-version" : "true", + "content-length" : "0", + "x-ms-lease-status" : "unlocked", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-lease-state" : "available", + "Last-Modified" : "Thu, 27 May 2021 19:31:51 GMT", + "x-ms-version-id" : "2021-05-27T19:31:52.5570663Z", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-blob-type" : "BlockBlob", + "x-ms-immutability-policy-mode" : "unlocked", + "x-ms-access-tier-inferred" : "true", + "x-ms-access-tier" : "Hot", + "x-ms-creation-time" : "Thu, 27 May 2021 19:31:51 GMT", + "eTag" : "0x8D92146141E7949", + "x-ms-request-id" : "72ac227a-501e-0090-122e-53e0ac000000", + "Content-Type" : "application/octet-stream", + "x-ms-last-access-time" : "Thu, 27 May 2021 19:31:51 GMT", + "x-ms-version" : "2020-10-02", + "x-ms-copy-id" : "11b3722b-93c1-4f73-a16e-15aab4bbc0ed", + "x-ms-immutability-policy-until-date" : "Thu, 27 May 2021 19:31:54 GMT", + "x-ms-copy-source" : "https://seanmcccanary3.blob.core.windows.net/d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962/d26dfd8c2d26dfd8c66c056963ddec71061124ac0a65", + "x-ms-copy-progress" : "0/0", + "x-ms-legal-hold" : "true", + "Date" : "Thu, 27 May 2021 19:31:51 GMT", + "Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==", + "Accept-Ranges" : "bytes", + "x-ms-copy-completion-time" : "Thu, 27 May 2021 19:31:51 GMT", + "x-ms-server-encrypted" : "true", + "x-ms-copy-status" : "success", + "x-ms-client-request-id" : "7eb58e7c-5c9b-4774-8a50-32adb6de31e0" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962?restype=container&comp=acl", + "Headers" : { + "x-ms-version" : "2020-10-02", + "User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "1fdb99bd-e71d-4e1d-b2f8-b2549626c48c", + "Content-Type" : "application/xml" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2020-10-02", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "eTag" : "0x8D9214614A358A0", + "Last-Modified" : "Thu, 27 May 2021 19:31:52 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "72ac228d-501e-0090-212e-53e0ac000000", + "x-ms-client-request-id" : "1fdb99bd-e71d-4e1d-b2f8-b2549626c48c", + "Date" : "Thu, 27 May 2021 19:31:52 GMT" + }, + "Exception" : null + } ], + "variables" : [ "d26dfd8c0d26dfd8c66c643965f9fa5d417fb493c876", "d26dfd8c1d26dfd8c66c760042309e5a7dac44cbe962", "d26dfd8c2d26dfd8c66c056963ddec71061124ac0a65", "d26dfd8c3d26dfd8c66c5153743fb081fb0274d9199a", "2021-05-27T19:31:52.581737600Z" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md index 2cfdc9d3b232a..31fbf55f2ecf8 100644 --- a/sdk/storage/azure-storage-blob/swagger/README.md +++ b/sdk/storage/azure-storage-blob/swagger/README.md @@ -29,7 +29,7 @@ license-header: MICROSOFT_MIT_SMALL context-client-method-parameter: true optional-constant-as-enum: true models-subpackage: implementation.models -custom-types: BlobAccessPolicy,AccessTier,AccountKind,ArchiveStatus,BlobHttpHeaders,BlobContainerItem,BlobContainerItemProperties,BlobContainerEncryptionScope,BlobServiceProperties,BlobType,Block,BlockList,BlockListType,BlockLookupList,BlobPrefix,ClearRange,CopyStatusType,BlobCorsRule,CpkInfo,CustomerProvidedKeyInfo,DeleteSnapshotsOptionType,EncryptionAlgorithmType,FilterBlobsItem,GeoReplication,GeoReplicationStatusType,KeyInfo,LeaseDurationType,LeaseStateType,LeaseStatusType,ListBlobContainersIncludeType,ListBlobsIncludeItem,BlobAnalyticsLogging,BlobMetrics,PageList,PageRange,PathRenameMode,PublicAccessType,RehydratePriority,BlobRetentionPolicy,SequenceNumberActionType,BlobSignedIdentifier,SkuName,StaticWebsite,BlobErrorCode,BlobServiceStatistics,SyncCopyStatusType,UserDelegationKey,BlobQueryHeaders,GeoReplicationStatus +custom-types: BlobAccessPolicy,AccessTier,AccountKind,ArchiveStatus,BlobHttpHeaders,BlobContainerItem,BlobContainerItemProperties,BlobContainerEncryptionScope,BlobServiceProperties,BlobType,Block,BlockList,BlockListType,BlockLookupList,BlobPrefix,ClearRange,CopyStatusType,BlobCorsRule,CpkInfo,CustomerProvidedKeyInfo,DeleteSnapshotsOptionType,EncryptionAlgorithmType,FilterBlobsItem,GeoReplication,GeoReplicationStatusType,KeyInfo,LeaseDurationType,LeaseStateType,LeaseStatusType,ListBlobContainersIncludeType,ListBlobsIncludeItem,BlobAnalyticsLogging,BlobMetrics,PageList,PageRange,PathRenameMode,PublicAccessType,RehydratePriority,BlobRetentionPolicy,SequenceNumberActionType,BlobSignedIdentifier,SkuName,StaticWebsite,BlobErrorCode,BlobServiceStatistics,SyncCopyStatusType,UserDelegationKey,BlobQueryHeaders,GeoReplicationStatus,BlobImmutabilityPolicyMode custom-types-subpackage: models customization-jar-path: target/azure-storage-blob-customization-1.0.0-beta.1.jar customization-class: com.azure.storage.blob.customization.BlobStorageCustomization @@ -727,6 +727,40 @@ directive: } ``` +### /{containerName}/{blob}?comp=immutabilityPolicies +``` yaml +directive: +- from: swagger-document + where: $["x-ms-paths"]["/{containerName}/{blob}?comp=immutabilityPolicies"] + transform: > + let putParam = $.put.parameters[0]; + if (!putParam["$ref"].endsWith("ContainerName")) { + const path = putParam["$ref"].replace(/[#].*$/, "#/parameters/"); + $.put.parameters.splice(0, 0, { "$ref": path + "ContainerName" }); + $.put.parameters.splice(1, 0, { "$ref": path + "Blob" }); + } + let deleteParam = $.delete.parameters[0]; + if (!deleteParam["$ref"].endsWith("ContainerName")) { + const path = deleteParam["$ref"].replace(/[#].*$/, "#/parameters/"); + $.delete.parameters.splice(0, 0, { "$ref": path + "ContainerName" }); + $.delete.parameters.splice(1, 0, { "$ref": path + "Blob" }); + } +``` + +### /{containerName}/{blob}?comp=legalhold +``` yaml +directive: +- from: swagger-document + where: $["x-ms-paths"]["/{containerName}/{blob}?comp=legalhold"] + transform: > + let param = $.put.parameters[0]; + if (!param["$ref"].endsWith("ContainerName")) { + const path = param["$ref"].replace(/[#].*$/, "#/parameters/"); + $.put.parameters.splice(0, 0, { "$ref": path + "ContainerName" }); + $.put.parameters.splice(1, 0, { "$ref": path + "Blob" }); + } +``` + ### BlobItemInternal ``` yaml directive: diff --git a/sdk/storage/azure-storage-blob/swagger/src/main/java/com/azure/storage/blob/customization/BlobStorageCustomization.java b/sdk/storage/azure-storage-blob/swagger/src/main/java/com/azure/storage/blob/customization/BlobStorageCustomization.java index ee81f7e2e0cac..8774460e0732f 100644 --- a/sdk/storage/azure-storage-blob/swagger/src/main/java/com/azure/storage/blob/customization/BlobStorageCustomization.java +++ b/sdk/storage/azure-storage-blob/swagger/src/main/java/com/azure/storage/blob/customization/BlobStorageCustomization.java @@ -35,6 +35,9 @@ public void customize(LibraryCustomization customization) { modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("undelete")); modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("setExpiry")); modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("setHttpHeaders")); + modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("setImmutabilityPolicy")); + modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("deleteImmutabilityPolicy")); + modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("setLegalHold")); modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("setMetadata")); modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("acquireLease")); modifyUnexpectedResponseExceptionType(blobsImpl.getMethod("releaseLease")); @@ -132,6 +135,7 @@ public void customize(LibraryCustomization customization) { ClassCustomization blobContainerItemProperties = models.getClass("BlobContainerItemProperties"); blobContainerItemProperties.getMethod("isEncryptionScopeOverridePrevented").setReturnType("boolean", "return Boolean.TRUE.equals(%s);", true); + blobContainerItemProperties.getMethod("setIsImmutableStorageWithVersioningEnabled").rename("setImmutableStorageWithVersioningEnabled"); // Block - Generator ClassCustomization block = models.getClass("Block"); diff --git a/sdk/storage/azure-storage-common/CHANGELOG.md b/sdk/storage/azure-storage-common/CHANGELOG.md index a6fb8cb85dfa6..1a4ea76ec1f5f 100644 --- a/sdk/storage/azure-storage-common/CHANGELOG.md +++ b/sdk/storage/azure-storage-common/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## 12.12.0-beta.2 (Unreleased) - +- Added support for the set immutability policy permission for Account SAS. ## 12.12.0-beta.1 (2021-05-13) - Fixed bug in Utility.convertStreamToByteBuffer where variable updates would happen incorrectly if we hit the end of stream. diff --git a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java index 334006a3daed9..31d8ac1617742 100644 --- a/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java +++ b/sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/sas/AccountSasPermission.java @@ -45,6 +45,8 @@ public final class AccountSasPermission { private boolean filterTagsPermission; + private boolean immutabilityPolicyPermission; + /** * Initializes an {@link AccountSasPermission} object with all fields set to false. */ @@ -59,8 +61,8 @@ public AccountSasPermission() { * * @return An {@link AccountSasPermission} object generated from the given {@link String}. * - * @throws IllegalArgumentException If {@code permissionString} contains a character other than r, w, d, x, l, a, c, u, p, - * t or f. + * @throws IllegalArgumentException If {@code permString} contains a character other than r, w, d, x, l, a, c, u, p, + * t, f or i. */ public static AccountSasPermission parse(String permissionString) { AccountSasPermission permissions = new AccountSasPermission(); @@ -101,6 +103,9 @@ public static AccountSasPermission parse(String permissionString) { case 'f': permissions.filterTagsPermission = true; break; + case 'i': + permissions.immutabilityPolicyPermission = true; + break; default: throw new IllegalArgumentException( String.format(Locale.ROOT, Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE, @@ -304,7 +309,6 @@ public AccountSasPermission setTagsPermission(boolean tagsPermission) { return this; } - /** * @return the filter tags permission status. */ @@ -323,6 +327,24 @@ public AccountSasPermission setFilterTagsPermission(boolean filterTagsPermission return this; } + /** + * @return the set immutability policy permission status. + */ + public boolean hasImmutabilityPolicyPermission() { + return immutabilityPolicyPermission; + } + + /** + * Sets the set immutability policy permission status. + * + * @param immutabilityPolicyPermission Permission status to set + * @return the updated AccountSasPermission object. + */ + public AccountSasPermission setImmutabilityPolicyPermission(boolean immutabilityPolicyPermission) { + this.immutabilityPolicyPermission = immutabilityPolicyPermission; + return this; + } + /** * Converts the given permissions to a {@link String}. Using this method will guarantee the permissions are in an * order accepted by the service. @@ -379,6 +401,10 @@ public String toString() { builder.append('f'); } + if (this.immutabilityPolicyPermission) { + builder.append('i'); + } + return builder.toString(); } } diff --git a/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/SasModelsTest.groovy b/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/SasModelsTest.groovy index a59d5ae74c126..520a86fdc331d 100644 --- a/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/SasModelsTest.groovy +++ b/sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/implementation/SasModelsTest.groovy @@ -92,24 +92,26 @@ class SasModelsTest extends Specification { .setDeleteVersionPermission(deleteVersion) .setTagsPermission(tags) .setFilterTagsPermission(filterTags) + .setImmutabilityPolicyPermission(setImmutabilityPolicy) expect: perms.toString() == expectedString where: - read | write | delete | list | add | create | update | process | deleteVersion | tags | filterTags || expectedString - true | false | false | false | false | false | false | false | false | false | false || "r" - false | true | false | false | false | false | false | false | false | false | false || "w" - false | false | true | false | false | false | false | false | false | false | false || "d" - false | false | false | true | false | false | false | false | false | false | false || "l" - false | false | false | false | true | false | false | false | false | false | false || "a" - false | false | false | false | false | true | false | false | false | false | false || "c" - false | false | false | false | false | false | true | false | false | false | false || "u" - false | false | false | false | false | false | false | true | false | false | false || "p" - false | false | false | false | false | false | false | false | true | false | false || "x" - false | false | false | false | false | false | false | false | false | true | false || "t" - false | false | false | false | false | false | false | false | false | false | true || "f" - true | true | true | true | true | true | true | true | true | true | true || "rwdxlacuptf" + read | write | delete | list | add | create | update | process | deleteVersion | tags | filterTags | setImmutabilityPolicy || expectedString + true | false | false | false | false | false | false | false | false | false | false | false || "r" + false | true | false | false | false | false | false | false | false | false | false | false || "w" + false | false | true | false | false | false | false | false | false | false | false | false || "d" + false | false | false | true | false | false | false | false | false | false | false | false || "l" + false | false | false | false | true | false | false | false | false | false | false | false || "a" + false | false | false | false | false | true | false | false | false | false | false | false || "c" + false | false | false | false | false | false | true | false | false | false | false | false || "u" + false | false | false | false | false | false | false | true | false | false | false | false || "p" + false | false | false | false | false | false | false | false | true | false | false | false || "x" + false | false | false | false | false | false | false | false | false | true | false | false || "t" + false | false | false | false | false | false | false | false | false | false | true | false || "f" + false | false | false | false | false | false | false | false | false | false | false | true || "i" + true | true | true | true | true | true | true | true | true | true | true | true || "rwdxlacuptfi" } @Unroll @@ -129,22 +131,24 @@ class SasModelsTest extends Specification { perms.hasDeleteVersionPermission() == deleteVersion perms.hasTagsPermission() == tags perms.hasFilterTagsPermission() == filterTags + perms.hasImmutabilityPolicyPermission() == immutabilityPolicy where: - permString || read | write | delete | list | add | create | update | process | deleteVersion | tags | filterTags - "r" || true | false | false | false | false | false | false | false | false | false | false - "w" || false | true | false | false | false | false | false | false | false | false | false - "d" || false | false | true | false | false | false | false | false | false | false | false - "l" || false | false | false | true | false | false | false | false | false | false | false - "a" || false | false | false | false | true | false | false | false | false | false | false - "c" || false | false | false | false | false | true | false | false | false | false | false - "u" || false | false | false | false | false | false | true | false | false | false | false - "p" || false | false | false | false | false | false | false | true | false | false | false - "x" || false | false | false | false | false | false | false | false | true | false | false - "t" || false | false | false | false | false | false | false | false | false | true | false - "f" || false | false | false | false | false | false | false | false | false | false | true - "rwdxlacuptf" || true | true | true | true | true | true | true | true | true | true | true - "lwfrutpcaxd" || true | true | true | true | true | true | true | true | true | true | true + permString || read | write | delete | list | add | create | update | process | deleteVersion | tags | filterTags | immutabilityPolicy + "r" || true | false | false | false | false | false | false | false | false | false | false | false + "w" || false | true | false | false | false | false | false | false | false | false | false | false + "d" || false | false | true | false | false | false | false | false | false | false | false | false + "l" || false | false | false | true | false | false | false | false | false | false | false | false + "a" || false | false | false | false | true | false | false | false | false | false | false | false + "c" || false | false | false | false | false | true | false | false | false | false | false | false + "u" || false | false | false | false | false | false | true | false | false | false | false | false + "p" || false | false | false | false | false | false | false | true | false | false | false | false + "x" || false | false | false | false | false | false | false | false | true | false | false | false + "t" || false | false | false | false | false | false | false | false | false | true | false | false + "f" || false | false | false | false | false | false | false | false | false | false | true | false + "i" || false | false | false | false | false | false | false | false | false | false | false | true + "rwdxlacuptfi" || true | true | true | true | true | true | true | true | true | true | true | true + "lwfriutpcaxd" || true | true | true | true | true | true | true | true | true | true | true | true } def "AccountSASPermissions parse IA"() {