From b53ec8c53dcd15e39605f90ba93c9290d8294440 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 8 Dec 2021 06:49:32 +0000 Subject: [PATCH] CodeGen from PR 17000 in Azure/azure-rest-api-specs Merge b8f4bd0d372cf55a11abe6354f824d191216cb5d into 5a1b7262be0a4f6a9004d35403b854429475cdf4 --- .../Generated/IStorageSyncManagementClient.cs | 21 ++ .../Models/LocationOperationStatus.cs | 99 ++++++++ .../Models/LocationOperationStatusHeaders.cs | 62 +++++ .../Generated/SdkInfo_MicrosoftStorageSync.cs | 12 +- .../Generated/StorageSyncManagementClient.cs | 220 ++++++++++++++++++ .../StorageSyncManagementClientExtensions.cs | 65 ++++++ 6 files changed, 468 insertions(+), 11 deletions(-) create mode 100644 sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatus.cs create mode 100644 sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatusHeaders.cs create mode 100644 sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClientExtensions.cs diff --git a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/IStorageSyncManagementClient.cs b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/IStorageSyncManagementClient.cs index f812f6583e9d..217984bdb9b5 100644 --- a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/IStorageSyncManagementClient.cs +++ b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/IStorageSyncManagementClient.cs @@ -14,6 +14,10 @@ namespace Microsoft.Azure.Management.StorageSync using Microsoft.Rest.Azure; using Models; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; /// /// Microsoft Storage Sync Service API @@ -119,5 +123,22 @@ public partial interface IStorageSyncManagementClient : System.IDisposable /// IOperationStatusOperations OperationStatus { get; } + /// + /// Get Operation status + /// + /// + /// The desired region to obtain information from. + /// + /// + /// operation Id + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> LocationOperationStatusMethodWithHttpMessagesAsync(string locationName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } } diff --git a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatus.cs b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatus.cs new file mode 100644 index 000000000000..ad04e22012b0 --- /dev/null +++ b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatus.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.StorageSync.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation status object + /// + public partial class LocationOperationStatus + { + /// + /// Initializes a new instance of the LocationOperationStatus class. + /// + public LocationOperationStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LocationOperationStatus class. + /// + /// Operation resource Id + /// Operation Id + /// Operation status + /// Start time of the operation + /// End time of the operation + /// Error details. + /// Percent complete. + public LocationOperationStatus(string id = default(string), string name = default(string), string status = default(string), System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), StorageSyncApiError error = default(StorageSyncApiError), int? percentComplete = default(int?)) + { + Id = id; + Name = name; + Status = status; + StartTime = startTime; + EndTime = endTime; + Error = error; + PercentComplete = percentComplete; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets operation Id + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets operation status + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets start time of the operation + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; private set; } + + /// + /// Gets end time of the operation + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; private set; } + + /// + /// Gets error details. + /// + [JsonProperty(PropertyName = "error")] + public StorageSyncApiError Error { get; private set; } + + /// + /// Gets percent complete. + /// + [JsonProperty(PropertyName = "percentComplete")] + public int? PercentComplete { get; private set; } + + } +} diff --git a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatusHeaders.cs b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatusHeaders.cs new file mode 100644 index 000000000000..51fc360dd9f6 --- /dev/null +++ b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/Models/LocationOperationStatusHeaders.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.StorageSync.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for LocationOperationStatus operation. + /// + public partial class LocationOperationStatusHeaders + { + /// + /// Initializes a new instance of the LocationOperationStatusHeaders + /// class. + /// + public LocationOperationStatusHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LocationOperationStatusHeaders + /// class. + /// + /// request id. + /// correlation request + /// id. + public LocationOperationStatusHeaders(string xMsRequestId = default(string), string xMsCorrelationRequestId = default(string)) + { + XMsRequestId = xMsRequestId; + XMsCorrelationRequestId = xMsCorrelationRequestId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets request id. + /// + [JsonProperty(PropertyName = "x-ms-request-id")] + public string XMsRequestId { get; set; } + + /// + /// Gets or sets correlation request id. + /// + [JsonProperty(PropertyName = "x-ms-correlation-request-id")] + public string XMsCorrelationRequestId { get; set; } + + } +} diff --git a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/SdkInfo_MicrosoftStorageSync.cs b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/SdkInfo_MicrosoftStorageSync.cs index 43be7cb808ba..e5395a50b23e 100644 --- a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/SdkInfo_MicrosoftStorageSync.cs +++ b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/SdkInfo_MicrosoftStorageSync.cs @@ -20,6 +20,7 @@ public static IEnumerable> ApiInfo_MicrosoftStorag return new Tuple[] { new Tuple("StorageSync", "CloudEndpoints", "2020-09-01"), + new Tuple("StorageSync", "LocationOperationStatus", "2020-09-01"), new Tuple("StorageSync", "OperationStatus", "2020-09-01"), new Tuple("StorageSync", "Operations", "2020-09-01"), new Tuple("StorageSync", "PrivateEndpointConnections", "2020-09-01"), @@ -32,16 +33,5 @@ public static IEnumerable> ApiInfo_MicrosoftStorag }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storagesync/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=D:\\github\\anpint\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "e92d236d96ab4e229a9943ddea7a7534982a4028"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClient.cs b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClient.cs index f68cbd0bc102..364bb4231820 100644 --- a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClient.cs +++ b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClient.cs @@ -20,6 +20,8 @@ namespace Microsoft.Azure.Management.StorageSync using System.Linq; using System.Net; using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; /// /// Microsoft Storage Sync Service API @@ -410,5 +412,223 @@ private void Initialize() DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); } + /// + /// Get Operation status + /// + /// + /// The desired region to obtain information from. + /// + /// + /// operation Id + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> LocationOperationStatusMethodWithHttpMessagesAsync(string locationName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.SubscriptionId"); + } + if (SubscriptionId != null) + { + if (SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "SubscriptionId", 1); + } + } + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + if (ApiVersion != null) + { + if (ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "ApiVersion", 1); + } + } + if (locationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "locationName"); + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("locationName", locationName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "LocationOperationStatusMethod", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/operations/{operationId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(SubscriptionId)); + _url = _url.Replace("{locationName}", System.Uri.EscapeDataString(locationName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + List _queryParameters = new List(); + if (ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (GenerateClientRequestId != null && GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new StorageSyncErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + StorageSyncError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClientExtensions.cs b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClientExtensions.cs new file mode 100644 index 000000000000..a09d76f8f4af --- /dev/null +++ b/sdk/storagesync/Microsoft.Azure.Management.StorageSync/src/Generated/StorageSyncManagementClientExtensions.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.StorageSync +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for StorageSyncManagementClient. + /// + public static partial class StorageSyncManagementClientExtensions + { + /// + /// Get Operation status + /// + /// + /// The operations group for this extension method. + /// + /// + /// The desired region to obtain information from. + /// + /// + /// operation Id + /// + public static LocationOperationStatus LocationOperationStatusMethod(this IStorageSyncManagementClient operations, string locationName, string operationId) + { + return operations.LocationOperationStatusMethodAsync(locationName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Get Operation status + /// + /// + /// The operations group for this extension method. + /// + /// + /// The desired region to obtain information from. + /// + /// + /// operation Id + /// + /// + /// The cancellation token. + /// + public static async Task LocationOperationStatusMethodAsync(this IStorageSyncManagementClient operations, string locationName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.LocationOperationStatusMethodWithHttpMessagesAsync(locationName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}