diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/IOperationalInsightsManagementClient.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/IOperationalInsightsManagementClient.cs index 54bab35badaf..4a058a2672b1 100644 --- a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/IOperationalInsightsManagementClient.cs +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/IOperationalInsightsManagementClient.cs @@ -14,6 +14,10 @@ namespace Microsoft.Azure.Management.OperationalInsights using Microsoft.Rest.Azure; using Models; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; /// /// Operational Insights Client @@ -91,5 +95,22 @@ public partial interface IOperationalInsightsManagementClient : System.IDisposab /// IOperations Operations { get; } + /// + /// Get the status of an azure asynchronous operation. + /// + /// + /// The region name of operation. + /// + /// + /// The operation Id. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetAsyncOperationsStatusWithHttpMessagesAsync(string location, string asyncOperationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } } diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/ErrorResponse.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..189d6d295c22 --- /dev/null +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/ErrorResponse.cs @@ -0,0 +1,60 @@ +// +// 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.OperationalInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes the format of Error response. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// Error code + /// Error message indicating why the operation + /// failed. + public ErrorResponse(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message indicating why the operation failed. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/OperationStatus.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/OperationStatus.cs new file mode 100644 index 000000000000..5ece076b7af3 --- /dev/null +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/OperationStatus.cs @@ -0,0 +1,92 @@ +// +// 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.OperationalInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The status of operation. + /// + public partial class OperationStatus + { + /// + /// Initializes a new instance of the OperationStatus class. + /// + public OperationStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationStatus class. + /// + /// The operation Id. + /// The operation name. + /// The start time of the operation. + /// The end time of the operation. + /// The status of the operation. + /// The error detail of the operation if + /// any. + public OperationStatus(string id = default(string), string name = default(string), string startTime = default(string), string endTime = default(string), string status = default(string), ErrorResponse error = default(ErrorResponse)) + { + Id = id; + Name = name; + StartTime = startTime; + EndTime = endTime; + Status = status; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operation Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the operation name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the start time of the operation. + /// + [JsonProperty(PropertyName = "startTime")] + public string StartTime { get; set; } + + /// + /// Gets or sets the end time of the operation. + /// + [JsonProperty(PropertyName = "endTime")] + public string EndTime { get; set; } + + /// + /// Gets or sets the status of the operation. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the error detail of the operation if any. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Sku.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Sku.cs index 11a915c31964..b3718819720e 100644 --- a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Sku.cs +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Sku.cs @@ -32,7 +32,7 @@ public Sku() /// /// The name of the SKU. Possible values include: /// 'Free', 'Standard', 'Premium', 'PerNode', 'PerGB2018', - /// 'Standalone' + /// 'Standalone', 'CapacityReservation' public Sku(string name) { Name = name; @@ -46,7 +46,8 @@ public Sku(string name) /// /// Gets or sets the name of the SKU. Possible values include: 'Free', - /// 'Standard', 'Premium', 'PerNode', 'PerGB2018', 'Standalone' + /// 'Standard', 'Premium', 'PerNode', 'PerGB2018', 'Standalone', + /// 'CapacityReservation' /// [JsonProperty(PropertyName = "name")] public string Name { get; set; } diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/SkuNameEnum.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/SkuNameEnum.cs index 4fcc4898c114..6f99cb627e0f 100644 --- a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/SkuNameEnum.cs +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/SkuNameEnum.cs @@ -22,5 +22,6 @@ public static class SkuNameEnum public const string PerNode = "PerNode"; public const string PerGB2018 = "PerGB2018"; public const string Standalone = "Standalone"; + public const string CapacityReservation = "CapacityReservation"; } } diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Workspace.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Workspace.cs index 091d4bf5445e..0112af133d31 100644 --- a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Workspace.cs +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/Models/Workspace.cs @@ -36,17 +36,13 @@ public Workspace() /// The provisioning state of the /// workspace. Possible values include: 'Creating', 'Succeeded', /// 'Failed', 'Canceled', 'Deleting', 'ProvisioningAccount' - /// The source of the workspace. Source defines - /// where the workspace was created. 'Azure' implies it was created in - /// Azure. 'External' implies it was created via the Operational - /// Insights Portal. This value is set on the service side and - /// read-only on the client side. - /// The ID associated with the workspace. - /// Setting this value at creation time allows the workspace being - /// created to be linked to an existing workspace. - /// The URL of the Operational Insights portal - /// for this workspace. This value is set on the service side and - /// read-only on the client side. + /// This is a read-only legacy property. It is + /// always set to 'Azure' by the service. Kept here for backward + /// compatibility. + /// This is a read-only property. Represents + /// the ID associated with the workspace. + /// This is a legacy property and is not used + /// anymore. Kept here for backward compatibility. /// The SKU of the workspace. /// The workspace data retention in days. /// -1 means Unlimited retention for the Unlimited Sku. 730 days is the @@ -78,30 +74,25 @@ public Workspace() public string ProvisioningState { get; set; } /// - /// Gets or sets the source of the workspace. Source defines where the - /// workspace was created. 'Azure' implies it was created in Azure. - /// 'External' implies it was created via the Operational Insights - /// Portal. This value is set on the service side and read-only on the - /// client side. + /// Gets this is a read-only legacy property. It is always set to + /// 'Azure' by the service. Kept here for backward compatibility. /// [JsonProperty(PropertyName = "properties.source")] - public string Source { get; set; } + public string Source { get; private set; } /// - /// Gets or sets the ID associated with the workspace. Setting this - /// value at creation time allows the workspace being created to be - /// linked to an existing workspace. + /// Gets this is a read-only property. Represents the ID associated + /// with the workspace. /// [JsonProperty(PropertyName = "properties.customerId")] - public string CustomerId { get; set; } + public string CustomerId { get; private set; } /// - /// Gets or sets the URL of the Operational Insights portal for this - /// workspace. This value is set on the service side and read-only on - /// the client side. + /// Gets this is a legacy property and is not used anymore. Kept here + /// for backward compatibility. /// [JsonProperty(PropertyName = "properties.portalUrl")] - public string PortalUrl { get; set; } + public string PortalUrl { get; private set; } /// /// Gets or sets the SKU of the workspace. diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClient.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClient.cs index f77a054bc722..cd4e2a018aa0 100644 --- a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClient.cs +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClient.cs @@ -20,6 +20,8 @@ namespace Microsoft.Azure.Management.OperationalInsights using System.Linq; using System.Net; using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; /// /// Operational Insights Client @@ -376,5 +378,201 @@ private void Initialize() DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); } + /// + /// Get the status of an azure asynchronous operation. + /// + /// + /// The region name of operation. + /// + /// + /// The 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> GetAsyncOperationsStatusWithHttpMessagesAsync(string location, string asyncOperationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "location"); + } + if (asyncOperationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "asyncOperationId"); + } + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + if (SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("location", location); + tracingParameters.Add("asyncOperationId", asyncOperationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAsyncOperationsStatus", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}").ToString(); + _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); + _url = _url.Replace("{asyncOperationId}", System.Uri.EscapeDataString(asyncOperationId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(SubscriptionId)); + 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClientExtensions.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClientExtensions.cs new file mode 100644 index 000000000000..9d1667ed39ff --- /dev/null +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/OperationalInsightsManagementClientExtensions.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.OperationalInsights +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for OperationalInsightsManagementClient. + /// + public static partial class OperationalInsightsManagementClientExtensions + { + /// + /// Get the status of an azure asynchronous operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region name of operation. + /// + /// + /// The operation Id. + /// + public static OperationStatus GetAsyncOperationsStatus(this IOperationalInsightsManagementClient operations, string location, string asyncOperationId) + { + return operations.GetAsyncOperationsStatusAsync(location, asyncOperationId).GetAwaiter().GetResult(); + } + + /// + /// Get the status of an azure asynchronous operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region name of operation. + /// + /// + /// The operation Id. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsyncOperationsStatusAsync(this IOperationalInsightsManagementClient operations, string location, string asyncOperationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAsyncOperationsStatusWithHttpMessagesAsync(location, asyncOperationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/SdkInfo_OperationalInsightsManagementClient.cs b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/SdkInfo_OperationalInsightsManagementClient.cs index 1f1b7917d893..e393b0211412 100644 --- a/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/SdkInfo_OperationalInsightsManagementClient.cs +++ b/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/SdkInfo_OperationalInsightsManagementClient.cs @@ -20,6 +20,7 @@ public static IEnumerable> ApiInfo_OperationalInsi return new Tuple[] { new Tuple("OperationalInsights", "DataSources", "2015-11-01-preview"), + new Tuple("OperationalInsights", "GetAsyncOperationsStatus", "2015-11-01-preview"), new Tuple("OperationalInsights", "LinkedServices", "2015-11-01-preview"), new Tuple("OperationalInsights", "Operations", "2015-11-01-preview"), new Tuple("OperationalInsights", "Workspaces", "2015-11-01-preview"),