diff --git a/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatch.cs b/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatch.cs index fcd8feb8b0ef..1665dc8c3ae4 100644 --- a/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatch.cs +++ b/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatch.cs @@ -99,13 +99,13 @@ private void SetBatchOperationType(BlobBatchOperationType operationType) #region DeleteBlob /// - /// The + /// The /// operation marks the specified blob or snapshot for deletion. The /// blob is later deleted during garbage collection. /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see /// . @@ -116,7 +116,7 @@ private void SetBatchOperationType(BlobBatchOperationType operationType) /// /// The name of the blob to delete. /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -131,7 +131,7 @@ private void SetBatchOperationType(BlobBatchOperationType operationType) public virtual Response DeleteBlob( string blobContainerName, string blobName, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default) { var blobUri = new BlobUriBuilder(_client.Uri) @@ -141,18 +141,18 @@ public virtual Response DeleteBlob( }; return DeleteBlob( blobUri.ToUri(), - deleteOptions, + snapshotsOption, accessConditions); } /// - /// The + /// The /// operation marks the specified blob or snapshot for deletion. The /// blob is later deleted during garbage collection. /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see /// . @@ -160,7 +160,7 @@ public virtual Response DeleteBlob( /// /// The blob to delete's primary endpoint. /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -174,14 +174,14 @@ public virtual Response DeleteBlob( /// public virtual Response DeleteBlob( Uri blobUri, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default) { SetBatchOperationType(BlobBatchOperationType.Delete); HttpMessage message = BlobRestClient.Blob.DeleteAsync_CreateMessage( _client.BatchOperationPipeline, blobUri, - deleteSnapshots: deleteOptions, + deleteSnapshots: snapshotsOption == DeleteSnapshotsOption.None ? null : (DeleteSnapshotsOption?)snapshotsOption, leaseId: accessConditions?.LeaseAccessConditions?.LeaseId, ifModifiedSince: accessConditions?.HttpAccessConditions?.IfModifiedSince, ifUnmodifiedSince: accessConditions?.HttpAccessConditions?.IfUnmodifiedSince, diff --git a/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatchClient.cs b/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatchClient.cs index 94c879e9b153..b2e1c33d9b6c 100644 --- a/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatchClient.cs +++ b/sdk/storage/Azure.Storage.Blobs.Batching/src/BlobBatchClient.cs @@ -441,7 +441,7 @@ private static async Task UpdateOperationResponses( /// that the operation should be cancelled. /// /// URIs of the blobs to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -455,11 +455,11 @@ private static async Task UpdateOperationResponses( [ForwardsClientCalls] public virtual Response[] DeleteBlobs( IEnumerable blobUris, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, CancellationToken cancellationToken = default) => DeleteBlobsInteral( blobUris, - deleteOptions, + snapshotsOption, false, // async cancellationToken) .EnsureCompleted(); @@ -474,7 +474,7 @@ public virtual Response[] DeleteBlobs( /// that the operation should be cancelled. /// /// URIs of the blobs to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -488,11 +488,11 @@ public virtual Response[] DeleteBlobs( [ForwardsClientCalls] public virtual async Task DeleteBlobsAsync( IEnumerable blobUris, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, CancellationToken cancellationToken = default) => await DeleteBlobsInteral( blobUris, - deleteOptions, + snapshotsOption, true, // async cancellationToken) .ConfigureAwait(false); @@ -503,7 +503,7 @@ await DeleteBlobsInteral( /// All of the deletions are sent as a single batched request. /// /// URIs of the blobs to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -523,7 +523,7 @@ await DeleteBlobsInteral( /// internal async Task DeleteBlobsInteral( IEnumerable blobUris, - DeleteSnapshotsOption? deleteOptions, + DeleteSnapshotsOption snapshotsOption, bool async, CancellationToken cancellationToken) { @@ -534,7 +534,7 @@ internal async Task DeleteBlobsInteral( BlobBatch batch = CreateBatch(); foreach (Uri uri in blobUris) { - responses.Add(batch.DeleteBlob(uri, deleteOptions)); + responses.Add(batch.DeleteBlob(uri, snapshotsOption)); } // Submit the batch diff --git a/sdk/storage/Azure.Storage.Blobs/samples/Sample03a_Batching.cs b/sdk/storage/Azure.Storage.Blobs/samples/Sample03a_Batching.cs index 55dd55d9b030..1bcd89fcdcac 100644 --- a/sdk/storage/Azure.Storage.Blobs/samples/Sample03a_Batching.cs +++ b/sdk/storage/Azure.Storage.Blobs/samples/Sample03a_Batching.cs @@ -112,7 +112,7 @@ public void FineGrainedBatching() // Create a batch with three deletes BlobBatchClient batchClient = service.GetBlobBatchClient(); BlobBatch batch = batchClient.CreateBatch(); - Response fooResponse = batch.DeleteBlob(foo.Uri, DeleteSnapshotsOption.Include); + Response fooResponse = batch.DeleteBlob(foo.Uri, DeleteSnapshotsOption.IncludeSnapshots); Response barResponse = batch.DeleteBlob(bar.Uri); Response bazResponse = batch.DeleteBlob(baz.Uri); diff --git a/sdk/storage/Azure.Storage.Blobs/samples/Sample03b_BatchingAsync.cs b/sdk/storage/Azure.Storage.Blobs/samples/Sample03b_BatchingAsync.cs index 1515940145c1..28d264466d47 100644 --- a/sdk/storage/Azure.Storage.Blobs/samples/Sample03b_BatchingAsync.cs +++ b/sdk/storage/Azure.Storage.Blobs/samples/Sample03b_BatchingAsync.cs @@ -113,7 +113,7 @@ public async Task FineGrainedBatchingAsync() // Create a batch with three deletes BlobBatchClient batchClient = service.GetBlobBatchClient(); BlobBatch batch = batchClient.CreateBatch(); - Response fooResponse = batch.DeleteBlob(foo.Uri, DeleteSnapshotsOption.Include); + Response fooResponse = batch.DeleteBlob(foo.Uri, DeleteSnapshotsOption.IncludeSnapshots); Response barResponse = batch.DeleteBlob(bar.Uri); Response bazResponse = batch.DeleteBlob(baz.Uri); diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index 3c8dacab12c2..ce5d527562df 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs @@ -1780,11 +1780,11 @@ private async Task AbortCopyFromUriInternal( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -1803,11 +1803,11 @@ private async Task AbortCopyFromUriInternal( /// a failure occurs. /// public virtual Response Delete( - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => DeleteInternal( - deleteOptions, + snapshotsOption, accessConditions, false, // async cancellationToken) @@ -1820,11 +1820,11 @@ public virtual Response Delete( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -1843,11 +1843,11 @@ public virtual Response Delete( /// a failure occurs. /// public virtual async Task DeleteAsync( - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => await DeleteInternal( - deleteOptions, + snapshotsOption, accessConditions, true, // async cancellationToken) @@ -1860,11 +1860,11 @@ await DeleteInternal( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -1883,11 +1883,11 @@ await DeleteInternal( /// a failure occurs. /// public virtual Response DeleteIfExists( - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => DeleteIfExistsInternal( - deleteOptions, + snapshotsOption, accessConditions ?? default, false, // async cancellationToken) @@ -1900,11 +1900,11 @@ public virtual Response DeleteIfExists( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -1923,11 +1923,11 @@ public virtual Response DeleteIfExists( /// a failure occurs. /// public virtual async Task> DeleteIfExistsAsync( - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => await DeleteIfExistsInternal( - deleteOptions, + snapshotsOption, accessConditions ?? default, true, // async cancellationToken) @@ -1940,11 +1940,11 @@ await DeleteIfExistsInternal( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -1966,7 +1966,7 @@ await DeleteIfExistsInternal( /// a failure occurs. /// private async Task> DeleteIfExistsInternal( - DeleteSnapshotsOption? deleteOptions, + DeleteSnapshotsOption snapshotsOption, BlobAccessConditions accessConditions, bool async, CancellationToken cancellationToken) @@ -1974,7 +1974,7 @@ private async Task> DeleteIfExistsInternal( try { Response response = await DeleteInternal( - deleteOptions, + snapshotsOption, accessConditions, async, cancellationToken, @@ -1996,11 +1996,11 @@ private async Task> DeleteIfExistsInternal( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -2025,7 +2025,7 @@ private async Task> DeleteIfExistsInternal( /// a failure occurs. /// private async Task DeleteInternal( - DeleteSnapshotsOption? deleteOptions, + DeleteSnapshotsOption snapshotsOption, BlobAccessConditions? accessConditions, bool async, CancellationToken cancellationToken, @@ -2037,7 +2037,7 @@ private async Task DeleteInternal( nameof(BlobBaseClient), message: $"{nameof(Uri)}: {Uri}\n" + - $"{nameof(deleteOptions)}: {deleteOptions}\n" + + $"{nameof(snapshotsOption)}: {snapshotsOption}\n" + $"{nameof(accessConditions)}: {accessConditions}"); try { @@ -2046,7 +2046,7 @@ private async Task DeleteInternal( Pipeline, Uri, leaseId: accessConditions?.LeaseAccessConditions?.LeaseId, - deleteSnapshots: deleteOptions, + deleteSnapshots: snapshotsOption == DeleteSnapshotsOption.None ? null : (DeleteSnapshotsOption?)snapshotsOption, ifModifiedSince: accessConditions?.HttpAccessConditions?.IfModifiedSince, ifUnmodifiedSince: accessConditions?.HttpAccessConditions?.IfUnmodifiedSince, ifMatch: accessConditions?.HttpAccessConditions?.IfMatch, diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs index 33d0fb40d487..aaa7df3c3a1d 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs @@ -1988,12 +1988,12 @@ await GetBlobClient(blobName) /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// /// The name of the blob to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -2014,12 +2014,12 @@ await GetBlobClient(blobName) [ForwardsClientCalls] public virtual Response DeleteBlob( string blobName, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => GetBlobClient(blobName) .Delete( - deleteOptions, + snapshotsOption, accessConditions, cancellationToken); @@ -2030,12 +2030,12 @@ public virtual Response DeleteBlob( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// /// The name of the blob to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -2056,12 +2056,12 @@ public virtual Response DeleteBlob( [ForwardsClientCalls] public virtual async Task DeleteBlobAsync( string blobName, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => await GetBlobClient(blobName) .DeleteAsync( - deleteOptions, + snapshotsOption, accessConditions, cancellationToken) .ConfigureAwait(false); @@ -2073,12 +2073,12 @@ await GetBlobClient(blobName) /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// /// The name of the blob to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -2099,12 +2099,12 @@ await GetBlobClient(blobName) [ForwardsClientCalls] public virtual Response DeleteBlobIfExists( string blobName, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => GetBlobClient(blobName). DeleteIfExists( - deleteOptions, + snapshotsOption, accessConditions ?? default, cancellationToken); @@ -2115,12 +2115,12 @@ public virtual Response DeleteBlobIfExists( /// /// Note that in order to delete a blob, you must delete all of its /// snapshots. You can delete both at the same time using - /// . + /// . /// /// For more information, see . /// /// The name of the blob to delete. - /// + /// /// Specifies options for deleting blob snapshots. /// /// @@ -2141,11 +2141,11 @@ public virtual Response DeleteBlobIfExists( [ForwardsClientCalls] public virtual async Task> DeleteBlobIfExistsAsync( string blobName, - DeleteSnapshotsOption? deleteOptions = default, + DeleteSnapshotsOption snapshotsOption = default, BlobAccessConditions? accessConditions = default, CancellationToken cancellationToken = default) => await GetBlobClient(blobName).DeleteIfExistsAsync( - deleteOptions, + snapshotsOption, accessConditions ?? default, cancellationToken) .ConfigureAwait(false); diff --git a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs index c90fa1cc0c13..bfae2cb37800 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs @@ -17219,15 +17219,20 @@ namespace Azure.Storage.Blobs.Models /// public enum DeleteSnapshotsOption { + /// + /// none + /// + None, + /// /// include /// - Include, + IncludeSnapshots, /// /// only /// - Only + OnlySnapshots } } @@ -17241,8 +17246,9 @@ public static string ToString(Azure.Storage.Blobs.Models.DeleteSnapshotsOption v { return value switch { - Azure.Storage.Blobs.Models.DeleteSnapshotsOption.Include => "include", - Azure.Storage.Blobs.Models.DeleteSnapshotsOption.Only => "only", + Azure.Storage.Blobs.Models.DeleteSnapshotsOption.None => null, + Azure.Storage.Blobs.Models.DeleteSnapshotsOption.IncludeSnapshots => "include", + Azure.Storage.Blobs.Models.DeleteSnapshotsOption.OnlySnapshots => "only", _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.DeleteSnapshotsOption value.") }; } @@ -17251,8 +17257,9 @@ public static Azure.Storage.Blobs.Models.DeleteSnapshotsOption ParseDeleteSnapsh { return value switch { - "include" => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.Include, - "only" => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.Only, + null => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.None, + "include" => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.IncludeSnapshots, + "only" => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.OnlySnapshots, _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.DeleteSnapshotsOption value.") }; } diff --git a/sdk/storage/Azure.Storage.Blobs/swagger/readme.md b/sdk/storage/Azure.Storage.Blobs/swagger/readme.md index aee7cd6cb672..37d2f2ecacaa 100644 --- a/sdk/storage/Azure.Storage.Blobs/swagger/readme.md +++ b/sdk/storage/Azure.Storage.Blobs/swagger/readme.md @@ -526,6 +526,9 @@ directive: where: $.parameters.DeleteSnapshots transform: > $["x-ms-enum"].name = "DeleteSnapshotsOption"; + $.enum = [ "none", "include", "only" ]; + $["x-ms-enum"].values = [ { name: "none", value: null }, { name: "IncludeSnapshots", value: "include" }, { name: "OnlySnapshots", value: "only" }]; + $["x-az-enum-skip-value"] = "none"; - from: swagger-document where: $.parameters.SequenceNumberAction transform: > diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs index 2ea7ae87d60b..e544e4252947 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs @@ -982,7 +982,7 @@ public async Task DeleteAsync_Options() await blob.CreateSnapshotAsync(); // Act - await blob.DeleteAsync(deleteOptions: DeleteSnapshotsOption.Only); + await blob.DeleteAsync(snapshotsOption: DeleteSnapshotsOption.OnlySnapshots); // Assert Response response = await blob.GetPropertiesAsync();