From baf683a25ac636fdf46362d90c10af1f66a8176e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 23 Mar 2023 01:43:45 +0000 Subject: [PATCH] CodeGen from PR 23218 in Azure/azure-rest-api-specs [Go] storagecache add directive (#23218) * [Go] storagecache add directive * fix --- ...urceManager.StorageCache.netstandard2.0.cs | 10 ++- .../Models/BlobNfsTarget.Serialization.cs | 34 +++++++- .../src/Generated/Models/BlobNfsTarget.cs | 10 ++- .../Models/Nfs3Target.Serialization.cs | 34 +++++++- .../src/Generated/Models/Nfs3Target.cs | 10 ++- .../RestOperations/AscUsagesRestOperations.cs | 2 +- .../RestOperations/CachesRestOperations.cs | 22 ++---- .../RestOperations/SkusRestOperations.cs | 2 +- .../StorageTargetsRestOperations.cs | 79 ++++++++++++++++++- .../UsageModelsRestOperations.cs | 2 +- .../src/Generated/StorageCacheResource.cs | 40 ++++++---- .../src/Generated/StorageTargetResource.cs | 68 ++++++++++++++++ .../src/autorest.md | 2 +- 13 files changed, 273 insertions(+), 42 deletions(-) diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/api/Azure.ResourceManager.StorageCache.netstandard2.0.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/api/Azure.ResourceManager.StorageCache.netstandard2.0.cs index 26286fe4fc2bd..f64ce6241cf0e 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/api/Azure.ResourceManager.StorageCache.netstandard2.0.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/api/Azure.ResourceManager.StorageCache.netstandard2.0.cs @@ -87,8 +87,8 @@ protected StorageCacheResource() { } public virtual System.Threading.Tasks.Task StopAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation StopPrimingJob(Azure.WaitUntil waitUntil, Azure.ResourceManager.StorageCache.Models.PrimingJobContent content = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StopPrimingJobAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.StorageCache.Models.PrimingJobContent content = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Update(Azure.ResourceManager.StorageCache.StorageCacheData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.StorageCache.StorageCacheData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.StorageCache.StorageCacheData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.StorageCache.StorageCacheData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation UpdateSpaceAllocation(Azure.WaitUntil waitUntil, System.Collections.Generic.IEnumerable spaceAllocation = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task UpdateSpaceAllocationAsync(Azure.WaitUntil waitUntil, System.Collections.Generic.IEnumerable spaceAllocation = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation UpgradeFirmware(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -140,6 +140,8 @@ protected StorageTargetResource() { } public virtual System.Threading.Tasks.Task InvalidateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation RefreshDns(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task RefreshDnsAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation RestoreDefaults(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task RestoreDefaultsAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation Resume(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task ResumeAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation Suspend(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -155,6 +157,8 @@ public partial class BlobNfsTarget public BlobNfsTarget() { } public Azure.Core.ResourceIdentifier Target { get { throw null; } set { } } public string UsageModel { get { throw null; } set { } } + public int? VerificationTimer { get { throw null; } set { } } + public int? WriteBackTimer { get { throw null; } set { } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct DomainJoinedType : System.IEquatable @@ -188,6 +192,8 @@ public partial class Nfs3Target public Nfs3Target() { } public string Target { get { throw null; } set { } } public string UsageModel { get { throw null; } set { } } + public int? VerificationTimer { get { throw null; } set { } } + public int? WriteBackTimer { get { throw null; } set { } } } public partial class NfsAccessPolicy { diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.Serialization.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.Serialization.cs index c53c893738da4..89c1e4c5b6046 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.Serialization.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.Serialization.cs @@ -25,6 +25,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("usageModel"u8); writer.WriteStringValue(UsageModel); } + if (Optional.IsDefined(VerificationTimer)) + { + writer.WritePropertyName("verificationTimer"u8); + writer.WriteNumberValue(VerificationTimer.Value); + } + if (Optional.IsDefined(WriteBackTimer)) + { + writer.WritePropertyName("writeBackTimer"u8); + writer.WriteNumberValue(WriteBackTimer.Value); + } writer.WriteEndObject(); } @@ -36,6 +46,8 @@ internal static BlobNfsTarget DeserializeBlobNfsTarget(JsonElement element) } Optional target = default; Optional usageModel = default; + Optional verificationTimer = default; + Optional writeBackTimer = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("target"u8)) @@ -53,8 +65,28 @@ internal static BlobNfsTarget DeserializeBlobNfsTarget(JsonElement element) usageModel = property.Value.GetString(); continue; } + if (property.NameEquals("verificationTimer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + verificationTimer = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("writeBackTimer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + writeBackTimer = property.Value.GetInt32(); + continue; + } } - return new BlobNfsTarget(target.Value, usageModel.Value); + return new BlobNfsTarget(target.Value, usageModel.Value, Optional.ToNullable(verificationTimer), Optional.ToNullable(writeBackTimer)); } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.cs index 71cbc891855d5..1b702a170bb3f 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/BlobNfsTarget.cs @@ -20,15 +20,23 @@ public BlobNfsTarget() /// Initializes a new instance of BlobNfsTarget. /// Resource ID of the storage container. /// Identifies the StorageCache usage model to be used for this storage target. - internal BlobNfsTarget(ResourceIdentifier target, string usageModel) + /// Amount of time (in seconds) the cache waits before it checks the back-end storage for file updates. + /// Amount of time (in seconds) the cache waits after the last file change before it copies the changed file to back-end storage. + internal BlobNfsTarget(ResourceIdentifier target, string usageModel, int? verificationTimer, int? writeBackTimer) { Target = target; UsageModel = usageModel; + VerificationTimer = verificationTimer; + WriteBackTimer = writeBackTimer; } /// Resource ID of the storage container. public ResourceIdentifier Target { get; set; } /// Identifies the StorageCache usage model to be used for this storage target. public string UsageModel { get; set; } + /// Amount of time (in seconds) the cache waits before it checks the back-end storage for file updates. + public int? VerificationTimer { get; set; } + /// Amount of time (in seconds) the cache waits after the last file change before it copies the changed file to back-end storage. + public int? WriteBackTimer { get; set; } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.Serialization.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.Serialization.cs index a9c3922f9636f..f0577c7bd625f 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.Serialization.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.Serialization.cs @@ -25,6 +25,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("usageModel"u8); writer.WriteStringValue(UsageModel); } + if (Optional.IsDefined(VerificationTimer)) + { + writer.WritePropertyName("verificationTimer"u8); + writer.WriteNumberValue(VerificationTimer.Value); + } + if (Optional.IsDefined(WriteBackTimer)) + { + writer.WritePropertyName("writeBackTimer"u8); + writer.WriteNumberValue(WriteBackTimer.Value); + } writer.WriteEndObject(); } @@ -36,6 +46,8 @@ internal static Nfs3Target DeserializeNfs3Target(JsonElement element) } Optional target = default; Optional usageModel = default; + Optional verificationTimer = default; + Optional writeBackTimer = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("target"u8)) @@ -48,8 +60,28 @@ internal static Nfs3Target DeserializeNfs3Target(JsonElement element) usageModel = property.Value.GetString(); continue; } + if (property.NameEquals("verificationTimer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + verificationTimer = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("writeBackTimer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + writeBackTimer = property.Value.GetInt32(); + continue; + } } - return new Nfs3Target(target.Value, usageModel.Value); + return new Nfs3Target(target.Value, usageModel.Value, Optional.ToNullable(verificationTimer), Optional.ToNullable(writeBackTimer)); } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.cs index 9fe7a46a48347..945b6869a49c6 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/Models/Nfs3Target.cs @@ -18,15 +18,23 @@ public Nfs3Target() /// Initializes a new instance of Nfs3Target. /// IP address or host name of an NFSv3 host (e.g., 10.0.44.44). /// Identifies the StorageCache usage model to be used for this storage target. - internal Nfs3Target(string target, string usageModel) + /// Amount of time (in seconds) the cache waits before it checks the back-end storage for file updates. + /// Amount of time (in seconds) the cache waits after the last file change before it copies the changed file to back-end storage. + internal Nfs3Target(string target, string usageModel, int? verificationTimer, int? writeBackTimer) { Target = target; UsageModel = usageModel; + VerificationTimer = verificationTimer; + WriteBackTimer = writeBackTimer; } /// IP address or host name of an NFSv3 host (e.g., 10.0.44.44). public string Target { get; set; } /// Identifies the StorageCache usage model to be used for this storage target. public string UsageModel { get; set; } + /// Amount of time (in seconds) the cache waits before it checks the back-end storage for file updates. + public int? VerificationTimer { get; set; } + /// Amount of time (in seconds) the cache waits after the last file change before it copies the changed file to back-end storage. + public int? WriteBackTimer { get; set; } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/AscUsagesRestOperations.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/AscUsagesRestOperations.cs index 47c615779e5d6..3478e43b28ebb 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/AscUsagesRestOperations.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/AscUsagesRestOperations.cs @@ -33,7 +33,7 @@ public AscUsagesRestOperations(HttpPipeline pipeline, string applicationId, Uri { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2022-05-01"; + _apiVersion = apiVersion ?? "2023-01-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/CachesRestOperations.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/CachesRestOperations.cs index ffac1a68654f1..07a3e17a25d94 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/CachesRestOperations.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/CachesRestOperations.cs @@ -34,7 +34,7 @@ public CachesRestOperations(HttpPipeline pipeline, string applicationId, Uri end { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2022-05-01"; + _apiVersion = apiVersion ?? "2023-01-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } @@ -444,7 +444,7 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG /// The cancellation token to use. /// , , or is null. /// , or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string cacheName, StorageCacheData data, CancellationToken cancellationToken = default) + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string cacheName, StorageCacheData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -456,12 +456,8 @@ public async Task> UpdateAsync(string subscriptionId, switch (message.Response.Status) { case 200: - { - StorageCacheData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = StorageCacheData.DeserializeStorageCacheData(document.RootElement); - return Response.FromValue(value, message.Response); - } + case 202: + return message.Response; default: throw new RequestFailedException(message.Response); } @@ -475,7 +471,7 @@ public async Task> UpdateAsync(string subscriptionId, /// The cancellation token to use. /// , , or is null. /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string cacheName, StorageCacheData data, CancellationToken cancellationToken = default) + public Response Update(string subscriptionId, string resourceGroupName, string cacheName, StorageCacheData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -487,12 +483,8 @@ public Response Update(string subscriptionId, string resourceG switch (message.Response.Status) { case 200: - { - StorageCacheData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = StorageCacheData.DeserializeStorageCacheData(document.RootElement); - return Response.FromValue(value, message.Response); - } + case 202: + return message.Response; default: throw new RequestFailedException(message.Response); } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/SkusRestOperations.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/SkusRestOperations.cs index 6e9684af66ea6..89f31c933f158 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/SkusRestOperations.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/SkusRestOperations.cs @@ -33,7 +33,7 @@ public SkusRestOperations(HttpPipeline pipeline, string applicationId, Uri endpo { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2022-05-01"; + _apiVersion = apiVersion ?? "2023-01-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/StorageTargetsRestOperations.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/StorageTargetsRestOperations.cs index 347b517b7d7fd..c2cb2e68a582f 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/StorageTargetsRestOperations.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/StorageTargetsRestOperations.cs @@ -33,7 +33,7 @@ public StorageTargetsRestOperations(HttpPipeline pipeline, string applicationId, { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2022-05-01"; + _apiVersion = apiVersion ?? "2023-01-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } @@ -767,6 +767,83 @@ public Response Invalidate(string subscriptionId, string resourceGroupName, stri } } + internal HttpMessage CreateRestoreDefaultsRequest(string subscriptionId, string resourceGroupName, string cacheName, string storageTargetName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.StorageCache/caches/", false); + uri.AppendPath(cacheName, true); + uri.AppendPath("/storageTargets/", false); + uri.AppendPath(storageTargetName, true); + uri.AppendPath("/restoreDefaults", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Tells a storage target to restore its settings to their default values. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// Target resource group. + /// Name of Cache. Length of name must not be greater than 80 and chars must be from the [-0-9a-zA-Z_] char class. + /// Name of Storage Target. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task RestoreDefaultsAsync(string subscriptionId, string resourceGroupName, string cacheName, string storageTargetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cacheName, nameof(cacheName)); + Argument.AssertNotNullOrEmpty(storageTargetName, nameof(storageTargetName)); + + using var message = CreateRestoreDefaultsRequest(subscriptionId, resourceGroupName, cacheName, storageTargetName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Tells a storage target to restore its settings to their default values. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// Target resource group. + /// Name of Cache. Length of name must not be greater than 80 and chars must be from the [-0-9a-zA-Z_] char class. + /// Name of Storage Target. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response RestoreDefaults(string subscriptionId, string resourceGroupName, string cacheName, string storageTargetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cacheName, nameof(cacheName)); + Argument.AssertNotNullOrEmpty(storageTargetName, nameof(storageTargetName)); + + using var message = CreateRestoreDefaultsRequest(subscriptionId, resourceGroupName, cacheName, storageTargetName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + internal HttpMessage CreateListByCacheNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string cacheName) { var message = _pipeline.CreateMessage(); diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/UsageModelsRestOperations.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/UsageModelsRestOperations.cs index eccc8b184a0f4..d702338aabc88 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/UsageModelsRestOperations.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/RestOperations/UsageModelsRestOperations.cs @@ -33,7 +33,7 @@ public UsageModelsRestOperations(HttpPipeline pipeline, string applicationId, Ur { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2022-05-01"; + _apiVersion = apiVersion ?? "2023-01-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageCacheResource.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageCacheResource.cs index 3f2ea1489ecf6..5953a3370daee 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageCacheResource.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageCacheResource.cs @@ -287,10 +287,11 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// Object containing the user-selectable properties of the Cache. If read-only properties are included, they must match the existing values of those properties. /// The cancellation token to use. /// is null. - public virtual async Task> UpdateAsync(StorageCacheData data, CancellationToken cancellationToken = default) + public virtual async Task> UpdateAsync(WaitUntil waitUntil, StorageCacheData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); @@ -299,7 +300,10 @@ public virtual async Task> UpdateAsync(StorageCac try { var response = await _storageCacheCachesRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new StorageCacheResource(Client, response.Value), response.GetRawResponse()); + var operation = new StorageCacheArmOperation(new StorageCacheOperationSource(Client), _storageCacheCachesClientDiagnostics, Pipeline, _storageCacheCachesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; } catch (Exception e) { @@ -321,10 +325,11 @@ public virtual async Task> UpdateAsync(StorageCac /// /// /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// Object containing the user-selectable properties of the Cache. If read-only properties are included, they must match the existing values of those properties. /// The cancellation token to use. /// is null. - public virtual Response Update(StorageCacheData data, CancellationToken cancellationToken = default) + public virtual ArmOperation Update(WaitUntil waitUntil, StorageCacheData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); @@ -333,7 +338,10 @@ public virtual Response Update(StorageCacheData data, Canc try { var response = _storageCacheCachesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken); - return Response.FromValue(new StorageCacheResource(Client, response.Value), response.GetRawResponse()); + var operation = new StorageCacheArmOperation(new StorageCacheOperationSource(Client), _storageCacheCachesClientDiagnostics, Pipeline, _storageCacheCachesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; } catch (Exception e) { @@ -1075,8 +1083,8 @@ public virtual async Task> AddTagAsync(string key patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -1129,8 +1137,8 @@ public virtual Response AddTag(string key, string value, C patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(patch, cancellationToken: cancellationToken); - return result; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -1178,8 +1186,8 @@ public virtual async Task> SetTagsAsync(IDictiona var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; var patch = new StorageCacheData(current.Location); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -1227,8 +1235,8 @@ public virtual Response SetTags(IDictionary> RemoveTagAsync(string patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -1331,8 +1339,8 @@ public virtual Response RemoveTag(string key, Cancellation patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(patch, cancellationToken: cancellationToken); - return result; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageTargetResource.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageTargetResource.cs index 2823907b236f4..75103963af4ad 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageTargetResource.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/Generated/StorageTargetResource.cs @@ -635,5 +635,73 @@ public virtual ArmOperation Invalidate(WaitUntil waitUntil, CancellationToken ca throw; } } + + /// + /// Tells a storage target to restore its settings to their default values. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/restoreDefaults + /// + /// + /// Operation Id + /// StorageTargets_RestoreDefaults + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task RestoreDefaultsAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _storageTargetClientDiagnostics.CreateScope("StorageTargetResource.RestoreDefaults"); + scope.Start(); + try + { + var response = await _storageTargetRestClient.RestoreDefaultsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new StorageCacheArmOperation(_storageTargetClientDiagnostics, Pipeline, _storageTargetRestClient.CreateRestoreDefaultsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tells a storage target to restore its settings to their default values. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/restoreDefaults + /// + /// + /// Operation Id + /// StorageTargets_RestoreDefaults + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation RestoreDefaults(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _storageTargetClientDiagnostics.CreateScope("StorageTargetResource.RestoreDefaults"); + scope.Start(); + try + { + var response = _storageTargetRestClient.RestoreDefaults(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new StorageCacheArmOperation(_storageTargetClientDiagnostics, Pipeline, _storageTargetRestClient.CreateRestoreDefaultsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/autorest.md b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/autorest.md index 7d7f848197417..e61fd813efe80 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/src/autorest.md +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/src/autorest.md @@ -9,7 +9,7 @@ generate-model-factory: false csharp: true library-name: StorageCache namespace: Azure.ResourceManager.StorageCache -require: https://github.com/Azure/azure-rest-api-specs/blob/53b1affe357b3bfbb53721d0a2002382a046d3b0/specification/storagecache/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/storagecache/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true skip-csproj: true