Skip to content

Commit 1f45626

Browse files
authored
Added ShareSnapshotNotFound in ShareErrorCode 99 (#48975)
* Generated Swagger changes for ShareSnapshotNotFoundValue added in ShareErrorCode * Fixed autorest.md * fixed autorest.md * exported apis * ShareClient.DeleteIfExists catches ShareSnapshotNotFound * tiny test fix * autorest + recorded tests * Recorded test
1 parent 1bfb10a commit 1f45626

8 files changed

Lines changed: 27 additions & 3 deletions

File tree

sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.net6.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ public ShareDirectorySetHttpHeadersOptions() { }
815815
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareNotFound { get { throw null; } }
816816
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotCountExceeded { get { throw null; } }
817817
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotInProgress { get { throw null; } }
818+
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotNotFound { get { throw null; } }
818819
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotOperationNotSupported { get { throw null; } }
819820
public static Azure.Storage.Files.Shares.Models.ShareErrorCode SharingViolation { get { throw null; } }
820821
public static Azure.Storage.Files.Shares.Models.ShareErrorCode UnsupportedHeader { get { throw null; } }

sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.net8.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ public ShareDirectorySetHttpHeadersOptions() { }
815815
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareNotFound { get { throw null; } }
816816
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotCountExceeded { get { throw null; } }
817817
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotInProgress { get { throw null; } }
818+
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotNotFound { get { throw null; } }
818819
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotOperationNotSupported { get { throw null; } }
819820
public static Azure.Storage.Files.Shares.Models.ShareErrorCode SharingViolation { get { throw null; } }
820821
public static Azure.Storage.Files.Shares.Models.ShareErrorCode UnsupportedHeader { get { throw null; } }

sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.netstandard2.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ public ShareDirectorySetHttpHeadersOptions() { }
815815
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareNotFound { get { throw null; } }
816816
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotCountExceeded { get { throw null; } }
817817
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotInProgress { get { throw null; } }
818+
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotNotFound { get { throw null; } }
818819
public static Azure.Storage.Files.Shares.Models.ShareErrorCode ShareSnapshotOperationNotSupported { get { throw null; } }
819820
public static Azure.Storage.Files.Shares.Models.ShareErrorCode SharingViolation { get { throw null; } }
820821
public static Azure.Storage.Files.Shares.Models.ShareErrorCode UnsupportedHeader { get { throw null; } }

sdk/storage/Azure.Storage.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.Files.Shares_2664069888"
5+
"Tag": "net/storage/Azure.Storage.Files.Shares_8e80a47735"
66
}

sdk/storage/Azure.Storage.Files.Shares/src/Generated/Models/ShareErrorCode.cs

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,8 @@ private async Task<Response<bool>> DeleteIfExistsInternal(
14231423
return Response.FromValue(true, response);
14241424
}
14251425
catch (RequestFailedException storageRequestFailedException)
1426-
when (storageRequestFailedException.ErrorCode == ShareErrorCode.ShareNotFound)
1426+
when (storageRequestFailedException.ErrorCode == ShareErrorCode.ShareNotFound
1427+
|| storageRequestFailedException.ErrorCode == ShareErrorCode.ShareSnapshotNotFound)
14271428
{
14281429
return Response.FromValue(false, default);
14291430
}

sdk/storage/Azure.Storage.Files.Shares/src/autorest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code.
44

55
``` yaml
66
input-file:
7-
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7dcad34e88d292bc09c89b279a77d6330f5a04f8/specification/storage/data-plane/Microsoft.FileStorage/stable/2025-11-05/file.json
7+
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/3946d872fb96fe085acd629c213b21794c756b71/specification/storage/data-plane/Microsoft.FileStorage/stable/2025-11-05/file.json
88
generation1-convenience-client: true
99
# https://github.com/Azure/autorest/issues/4075
1010
skip-semantics-validation: true

sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,23 @@ public async Task DeleteIfExistsAsync_NotExists()
945945
Assert.IsFalse(response.Value);
946946
}
947947

948+
[RecordedTest]
949+
public async Task DeleteIfExistsAsync_SnapshotNotFound()
950+
{
951+
// Arrange
952+
var shareName = GetNewShareName();
953+
ShareServiceClient service = SharesClientBuilder.GetServiceClient_SharedKey();
954+
ShareClient share = InstrumentClient(service.GetShareClient(shareName));
955+
await share.CreateIfNotExistsAsync();
956+
ShareClient shareWithSnapshot = share.WithSnapshot("2025-02-04T10:17:47.0000000Z");
957+
958+
// Act
959+
Response<bool> response = await shareWithSnapshot.DeleteIfExistsAsync();
960+
961+
// Assert
962+
Assert.IsFalse(response.Value);
963+
}
964+
948965
[RecordedTest]
949966
public async Task DeleteIfExistsAsync_Error()
950967
{

0 commit comments

Comments
 (0)