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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 55 additions & 37 deletions sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1820,13 +1820,16 @@ private async Task<Response> AbortCopyFromUriInternal(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -1844,11 +1847,11 @@ private async Task<Response> AbortCopyFromUriInternal(
/// a failure occurs.
/// </remarks>
public virtual Response Delete(
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
DeleteInternal(
deleteOptions,
includeSnapshots,
accessConditions,
false, // async
cancellationToken)
Expand All @@ -1860,13 +1863,16 @@ public virtual Response Delete(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -1884,11 +1890,11 @@ public virtual Response Delete(
/// a failure occurs.
/// </remarks>
public virtual async Task<Response> DeleteAsync(
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
await DeleteInternal(
deleteOptions,
includeSnapshots,
accessConditions,
true, // async
cancellationToken)
Expand All @@ -1900,13 +1906,16 @@ await DeleteInternal(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -1924,11 +1933,11 @@ await DeleteInternal(
/// a failure occurs.
/// </remarks>
public virtual Response<bool> DeleteIfExists(
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
DeleteIfExistsInternal(
deleteOptions,
includeSnapshots,
accessConditions ?? default,
false, // async
cancellationToken)
Expand All @@ -1940,13 +1949,16 @@ public virtual Response<bool> DeleteIfExists(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -1964,11 +1976,11 @@ public virtual Response<bool> DeleteIfExists(
/// a failure occurs.
/// </remarks>
public virtual async Task<Response<bool>> DeleteIfExistsAsync(
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
await DeleteIfExistsInternal(
deleteOptions,
includeSnapshots,
accessConditions ?? default,
true, // async
cancellationToken)
Expand All @@ -1980,13 +1992,16 @@ await DeleteIfExistsInternal(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -2007,15 +2022,15 @@ await DeleteIfExistsInternal(
/// a failure occurs.
/// </remarks>
private async Task<Response<bool>> DeleteIfExistsInternal(
DeleteSnapshotsOption? deleteOptions,
bool includeSnapshots,
BlobAccessConditions accessConditions,
bool async,
CancellationToken cancellationToken)
{
try
{
Response response = await DeleteInternal(
deleteOptions,
includeSnapshots,
accessConditions,
async,
cancellationToken,
Expand All @@ -2036,13 +2051,16 @@ private async Task<Response<bool>> DeleteIfExistsInternal(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -2066,7 +2084,7 @@ private async Task<Response<bool>> DeleteIfExistsInternal(
/// a failure occurs.
/// </remarks>
private async Task<Response> DeleteInternal(
DeleteSnapshotsOption? deleteOptions,
bool includeSnapshots,
BlobAccessConditions? accessConditions,
bool async,
CancellationToken cancellationToken,
Expand All @@ -2078,15 +2096,15 @@ private async Task<Response> DeleteInternal(
nameof(BlobBaseClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(deleteOptions)}: {deleteOptions}\n" +
$"{nameof(includeSnapshots)}: {includeSnapshots}\n" +
$"{nameof(accessConditions)}: {accessConditions}");
try
{
return await BlobRestClient.Blob.DeleteAsync(
Pipeline,
Uri,
leaseId: accessConditions?.LeaseAccessConditions?.LeaseId,
deleteSnapshots: deleteOptions,
deleteSnapshots: includeSnapshots == true ? DeleteSnapshotsOption.Include : DeleteSnapshotsOption.Only,
ifModifiedSince: accessConditions?.HttpAccessConditions?.IfModifiedSince,
ifUnmodifiedSince: accessConditions?.HttpAccessConditions?.IfUnmodifiedSince,
ifMatch: accessConditions?.HttpAccessConditions?.IfMatch,
Expand Down
60 changes: 36 additions & 24 deletions sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1908,14 +1908,17 @@ await GetBlobClient(blobName)
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="blobName">The name of the blob to delete.</param>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -1935,12 +1938,12 @@ await GetBlobClient(blobName)
[ForwardsClientCalls]
public virtual Response DeleteBlob(
string blobName,
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
GetBlobClient(blobName)
.Delete(
deleteOptions,
includeSnapshots,
accessConditions,
cancellationToken);

Expand All @@ -1950,14 +1953,17 @@ public virtual Response DeleteBlob(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="blobName">The name of the blob to delete.</param>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -1977,12 +1983,12 @@ public virtual Response DeleteBlob(
[ForwardsClientCalls]
public virtual async Task<Response> DeleteBlobAsync(
string blobName,
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
await GetBlobClient(blobName)
.DeleteAsync(
deleteOptions,
includeSnapshots,
accessConditions,
cancellationToken)
.ConfigureAwait(false);
Expand All @@ -1993,14 +1999,17 @@ await GetBlobClient(blobName)
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="blobName">The name of the blob to delete.</param>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -2020,12 +2029,12 @@ await GetBlobClient(blobName)
[ForwardsClientCalls]
public virtual Response<bool> DeleteBlobIfExists(
string blobName,
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
GetBlobClient(blobName).
DeleteIfExists(
deleteOptions,
includeSnapshots,
accessConditions ?? default,
cancellationToken);

Expand All @@ -2035,14 +2044,17 @@ public virtual Response<bool> DeleteBlobIfExists(
/// 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
/// <see cref="DeleteSnapshotsOption.Include"/>.
/// snapshots. You can delete both at the same time by passing includeSnapshots
/// as true.
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/delete-blob" />.
/// </summary>
/// <param name="blobName">The name of the blob to delete.</param>
/// <param name="deleteOptions">
/// Specifies options for deleting blob snapshots.
/// <param name="includeSnapshots">
/// Specify true or false for deleting blob snapshots:
/// true: Delete the base blob and all of its snapshots.
/// false: Delete only the blob's snapshots and not the blob itself.
/// Default is true.
/// </param>
/// <param name="accessConditions">
/// Optional <see cref="BlobAccessConditions"/> to add conditions on
Expand All @@ -2062,11 +2074,11 @@ public virtual Response<bool> DeleteBlobIfExists(
[ForwardsClientCalls]
public virtual async Task<Response<bool>> DeleteBlobIfExistsAsync(
string blobName,
DeleteSnapshotsOption? deleteOptions = default,
bool includeSnapshots = true,
BlobAccessConditions? accessConditions = default,
CancellationToken cancellationToken = default) =>
await GetBlobClient(blobName).DeleteIfExistsAsync(
deleteOptions,
includeSnapshots,
accessConditions ?? default,
cancellationToken)
.ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16670,7 +16670,7 @@ namespace Azure.Storage.Blobs.Models
/// <summary>
/// Required if the blob has associated snapshots. Specify one of the following two options: include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob itself
/// </summary>
public enum DeleteSnapshotsOption
internal enum DeleteSnapshotsOption
{
/// <summary>
/// include
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/Azure.Storage.Blobs/swagger/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ directive:
where: $.parameters.DeleteSnapshots
transform: >
$["x-ms-enum"].name = "DeleteSnapshotsOption";
$["x-az-public"] = false;
- from: swagger-document
where: $.parameters.SequenceNumberAction
transform: >
Expand Down
Loading