-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added Share Soft Delete #11260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Share Soft Delete #11260
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,12 @@ public class TestConfigurations | |
| /// </summary> | ||
| private string TargetManagedDiskTenantName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the name of the tenant in the Tenants dictionary to use for | ||
| /// any tests related to blob and container soft delete. | ||
| /// </summary> | ||
| private string TargetSoftDeleteTenantName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the tenant to use by default for our tests. | ||
| /// </summary> | ||
|
|
@@ -122,6 +128,12 @@ public class TestConfigurations | |
| public static TenantConfiguration DefaultTargetManagedDiskTenant => | ||
| GetTenant("TargetManagedDiskTenant", s_configurations.Value.TargetManagedDiskTenantName); | ||
|
|
||
| /// <summary> | ||
| /// Gets a tenant to use for any tests related to blob or container soft delete. | ||
| /// </summary> | ||
| public static TenantConfiguration DefaultTargetSoftDeleteTenant => | ||
| GetTenant("TargetBlobAndContainerSoftDeleteTenant", s_configurations.Value.TargetSoftDeleteTenantName); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is Soft Delete an account level setting that applies regardless of whether you're using Blobs/Files?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, there is Container Soft Delete and Blob Soft Delete for the Blobs service, and Share Soft Delete for Files. I'd like to just make 1 new test account with all soft delete features enabled. The reason I want a separate account is that 1. it takes time to enable/disable these features on an account, and 2. if you list with the "Deleted" option, and soft delete has been enabled for weeks, the resulting list could be huge.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it - I'm on board with the separate account. Just wonder if we should call the tenant name
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add additional documentation around what settings this tenant requres. |
||
|
|
||
| /// <summary> | ||
| /// When loading our test configuration, we'll check the | ||
| /// AZ_STORAGE_CONFIG_PATH first. | ||
|
|
@@ -219,6 +231,7 @@ private static TestConfigurations ReadFromXml(XDocument doc) | |
| TargetOAuthTenantName = Get("TargetOAuthTenant"), | ||
| TargetHierarchicalNamespaceTenantName = Get("TargetHierarchicalNamespaceTenant"), | ||
| TargetManagedDiskTenantName = Get("TargetManagedDiskTenant"), | ||
| TargetSoftDeleteTenantName = Get("TargetBlobAndContainerSoftDeleteTenant"), | ||
| Tenants = | ||
| config.Element("TenantConfigurations").Elements("TenantConfiguration") | ||
| .Select(TenantConfiguration.Parse) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1949,6 +1949,147 @@ private async Task<Response<PermissionInfo>> CreatePermissionInternal( | |
| } | ||
| #endregion CreatePermission | ||
|
|
||
| #region RestoreShare | ||
| /// <summary> | ||
| /// Restores a previously created share. The restored share | ||
| /// will be renamed to the name of this <see cref="ShareServiceClient"/>. | ||
| /// If the container associated with this <see cref="ShareServiceClient"/> | ||
| /// already exists, this call will result in a 409 (conflict). | ||
| /// This API is only functional is Share Soft Delete is enabled | ||
| /// for the storage account associated with the share. | ||
| /// </summary> | ||
| /// <param name="deletedShareName"> | ||
| /// The name of the share to restore. | ||
| /// </param> | ||
| /// <param name="deletedShareVersion"> | ||
| /// The version of the share to restore. | ||
| /// </param> | ||
| /// <param name="cancellationToken"> | ||
| /// Optional <see cref="CancellationToken"/> to propagate | ||
| /// notifications that the operation should be cancelled. | ||
| /// </param> | ||
| /// <returns> | ||
| /// A <see cref="Response"/>. | ||
| /// </returns> | ||
| /// <remarks> | ||
| /// A <see cref="RequestFailedException"/> will be thrown if | ||
| /// a failure occurs. | ||
| /// </remarks> | ||
| public virtual Response<ShareInfo> Restore( | ||
| string deletedShareName, | ||
| string deletedShareVersion, | ||
| CancellationToken cancellationToken = default) | ||
| => RestoreInternal( | ||
| deletedShareName, | ||
| deletedShareVersion, | ||
| async: false, | ||
| cancellationToken).EnsureCompleted(); | ||
|
|
||
| /// <summary> | ||
| /// Restores a previously created share. The restored share | ||
| /// will be renamed to the name of this <see cref="ShareServiceClient"/>. | ||
| /// If the container associated with this <see cref="ShareServiceClient"/> | ||
| /// already exists, this call will result in a 409 (conflict). | ||
| /// This API is only functional is Share Soft Delete is enabled | ||
| /// for the storage account associated with the share. | ||
| /// </summary> | ||
| /// <param name="deletedShareName"> | ||
| /// The name of the share to restore. | ||
| /// </param> | ||
| /// <param name="deletedShareVersion"> | ||
| /// The version of the share to restore. | ||
| /// </param> | ||
| /// <param name="cancellationToken"> | ||
| /// Optional <see cref="CancellationToken"/> to propagate | ||
| /// notifications that the operation should be cancelled. | ||
| /// </param> | ||
| /// <returns> | ||
| /// A <see cref="Response"/>. | ||
| /// </returns> | ||
| /// <remarks> | ||
| /// A <see cref="RequestFailedException"/> will be thrown if | ||
| /// a failure occurs | ||
| /// </remarks> | ||
| public virtual async Task<Response<ShareInfo>> RestoreAsync( | ||
| string deletedShareName, | ||
| string deletedShareVersion, | ||
| CancellationToken cancellationToken = default) | ||
| => await RestoreInternal( | ||
| deletedShareName, | ||
| deletedShareVersion, | ||
| async: true, | ||
| cancellationToken).ConfigureAwait(false); | ||
|
|
||
| /// <summary> | ||
| /// Restores a previously created share. The restored share | ||
| /// will be renamed to the name of this <see cref="ShareServiceClient"/>. | ||
| /// If the container associated with this <see cref="ShareServiceClient"/> | ||
| /// already exists, this call will result in a 409 (conflict). | ||
| /// This API is only functional is Share Soft Delete is enabled | ||
| /// for the storage account associated with the share. | ||
| /// </summary> | ||
| /// <param name="deletedShareName"> | ||
| /// The name of the share to restore. | ||
| /// </param> | ||
| /// <param name="deletedShareVersion"> | ||
| /// The version of the share to restore. | ||
| /// </param> | ||
| /// <param name="async"> | ||
| /// Whether to invoke the operation asynchronously. | ||
| /// </param> | ||
| /// <param name="cancellationToken"> | ||
| /// Optional <see cref="CancellationToken"/> to propagate | ||
| /// notifications that the operation should be cancelled. | ||
| /// </param> | ||
| /// <returns> | ||
| /// A <see cref="Response"/>. | ||
| /// </returns> | ||
| /// <remarks> | ||
| /// A <see cref="RequestFailedException"/> will be thrown if | ||
| /// a failure occurs. | ||
| /// </remarks> | ||
| private async Task<Response<ShareInfo>> RestoreInternal( | ||
| string deletedShareName, | ||
| string deletedShareVersion, | ||
| bool async, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| using (Pipeline.BeginLoggingScope(nameof(ShareServiceClient))) | ||
| { | ||
| Pipeline.LogMethodEnter( | ||
| nameof(ShareServiceClient), | ||
| message: | ||
| $"{nameof(Uri)}: {Uri}\n" + | ||
| $"{nameof(deletedShareName)}: {deletedShareName}\n" + | ||
| $"{nameof(deletedShareVersion)}: {deletedShareVersion}"); | ||
|
|
||
| try | ||
| { | ||
| return await FileRestClient.Share.RestoreAsync( | ||
| ClientDiagnostics, | ||
| Pipeline, | ||
| Uri, | ||
| Version.ToVersionString(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the operation just fail if you call this with an older service version? I can't imagine this causing any problems, but want to double check we don't need a version guard here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it will fail, with a message from the service saying the version is incorrect. Peter decided we weren't doing version guarding in the SDK.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it was specifically no guards unless it could lead to data corruption or loss - which is why I like double checking for some of these new operations.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing will happen to your share if you call Restore with a service version that doesn't support it - you will just get a 400 class error. |
||
| deletedShareName: deletedShareName, | ||
| deletedShareVersion: deletedShareVersion, | ||
| async: async, | ||
| operationName: $"{nameof(ShareClient)}.{nameof(Restore)}", | ||
| cancellationToken: cancellationToken) | ||
| .ConfigureAwait(false); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Pipeline.LogException(ex); | ||
| throw; | ||
| } | ||
| finally | ||
| { | ||
| Pipeline.LogMethodExit(nameof(ShareServiceClient)); | ||
| } | ||
| } | ||
| } | ||
| #endregion RestoreShare | ||
|
|
||
| #region CreateDirectory | ||
| /// <summary> | ||
| /// The <see cref="CreateDirectory"/> operation creates a new | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.