diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs index ac8bca7e529f..024aedbac907 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs @@ -69,7 +69,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -198,14 +198,13 @@ internal ActionGroupsOperations(MonitorManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -215,10 +214,6 @@ internal ActionGroupsOperations(MonitorManagementClient client) } 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); @@ -296,7 +291,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -408,16 +403,15 @@ internal ActionGroupsOperations(MonitorManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 404) + if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -427,10 +421,6 @@ internal ActionGroupsOperations(MonitorManagementClient client) } 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); @@ -490,7 +480,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -601,14 +591,13 @@ internal ActionGroupsOperations(MonitorManagementClient client) string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 204) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -618,10 +607,6 @@ internal ActionGroupsOperations(MonitorManagementClient client) } 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); @@ -657,7 +642,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -759,14 +744,13 @@ internal ActionGroupsOperations(MonitorManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -776,10 +760,6 @@ internal ActionGroupsOperations(MonitorManagementClient client) } 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); @@ -836,7 +816,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -944,14 +924,13 @@ internal ActionGroupsOperations(MonitorManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -961,10 +940,6 @@ internal ActionGroupsOperations(MonitorManagementClient client) } 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); @@ -1028,7 +1003,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -1153,16 +1128,15 @@ internal ActionGroupsOperations(MonitorManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 409 && (int)_statusCode != 404) + if ((int)_statusCode != 200 && (int)_statusCode != 409) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -1172,10 +1146,6 @@ internal ActionGroupsOperations(MonitorManagementClient client) } 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); diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsCategoryOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsCategoryOperations.cs new file mode 100644 index 000000000000..f901e201ec9a --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsCategoryOperations.cs @@ -0,0 +1,414 @@ +// 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.Monitor.Management +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DiagnosticSettingsCategoryOperations operations. + /// + internal partial class DiagnosticSettingsCategoryOperations : IServiceOperations, IDiagnosticSettingsCategoryOperations + { + /// + /// Initializes a new instance of the DiagnosticSettingsCategoryOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DiagnosticSettingsCategoryOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Gets the diagnostic settings category for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories/{name}").ToString(); + _url = _url.Replace("{resourceUri}", System.Uri.EscapeDataString(resourceUri)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.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 (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.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 = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.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; + } + + /// + /// Lists the diagnostic settings categories for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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> ListWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories").ToString(); + _url = _url.Replace("{resourceUri}", System.Uri.EscapeDataString(resourceUri)); + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.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 (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.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 = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.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/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsCategoryOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsCategoryOperationsExtensions.cs new file mode 100644 index 000000000000..1b370e128288 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsCategoryOperationsExtensions.cs @@ -0,0 +1,100 @@ +// 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.Monitor.Management +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DiagnosticSettingsCategoryOperations. + /// + public static partial class DiagnosticSettingsCategoryOperationsExtensions + { + /// + /// Gets the diagnostic settings category for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + public static DiagnosticSettingsCategoryResource Get(this IDiagnosticSettingsCategoryOperations operations, string resourceUri, string name) + { + return operations.GetAsync(resourceUri, name).GetAwaiter().GetResult(); + } + + /// + /// Gets the diagnostic settings category for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDiagnosticSettingsCategoryOperations operations, string resourceUri, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceUri, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the diagnostic settings categories for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + public static DiagnosticSettingsCategoryResourceCollection List(this IDiagnosticSettingsCategoryOperations operations, string resourceUri) + { + return operations.ListAsync(resourceUri).GetAwaiter().GetResult(); + } + + /// + /// Lists the diagnostic settings categories for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IDiagnosticSettingsCategoryOperations operations, string resourceUri, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsOperations.cs similarity index 69% rename from src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs rename to src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsOperations.cs index 9dc17c29714c..6e9b17de26d0 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsOperations.cs @@ -24,12 +24,12 @@ namespace Microsoft.Azure.Management.Monitor.Management using System.Threading.Tasks; /// - /// ServiceDiagnosticSettingsOperations operations. + /// DiagnosticSettingsOperations operations. /// - internal partial class ServiceDiagnosticSettingsOperations : IServiceOperations, IServiceDiagnosticSettingsOperations + internal partial class DiagnosticSettingsOperations : IServiceOperations, IDiagnosticSettingsOperations { /// - /// Initializes a new instance of the ServiceDiagnosticSettingsOperations class. + /// Initializes a new instance of the DiagnosticSettingsOperations class. /// /// /// Reference to the service client. @@ -37,7 +37,7 @@ internal partial class ServiceDiagnosticSettingsOperations : IServiceOperations< /// /// Thrown when a required parameter is null /// - internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) + internal DiagnosticSettingsOperations(MonitorManagementClient client) { if (client == null) { @@ -53,11 +53,13 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// Gets the active diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. /// /// /// The identifier of the resource. /// + /// + /// The name of the diagnostic setting. + /// /// /// Headers that will be added to request. /// @@ -79,13 +81,17 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceUri == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); } - string apiVersion = "2016-09-01"; + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2017-05-01-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -95,13 +101,15 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceUri", resourceUri); tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("name", name); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings/service").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}").ToString(); _url = _url.Replace("{resourceUri}", System.Uri.EscapeDataString(resourceUri)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); List _queryParameters = new List(); if (apiVersion != null) { @@ -195,7 +203,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -208,7 +216,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -228,8 +236,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) } /// - /// Create or update new diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. + /// Creates or updates diagnostic settings for the specified resource. /// /// /// The identifier of the resource. @@ -237,13 +244,16 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// Parameters supplied to the operation. /// + /// + /// The name of the diagnostic setting. + /// /// /// Headers that will be added to request. /// /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -258,7 +268,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceUri, DiagnosticSettingsResource parameters, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceUri == null) { @@ -272,7 +282,11 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) { parameters.Validate(); } - string apiVersion = "2016-09-01"; + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2017-05-01-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -283,13 +297,15 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) tracingParameters.Add("resourceUri", resourceUri); tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("parameters", parameters); + tracingParameters.Add("name", name); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings/service").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}").ToString(); _url = _url.Replace("{resourceUri}", System.Uri.EscapeDataString(resourceUri)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); List _queryParameters = new List(); if (apiVersion != null) { @@ -361,14 +377,13 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) string _responseContent = null; if ((int)_statusCode != 200) { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { - ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } @@ -378,10 +393,6 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) } 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); @@ -394,7 +405,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -407,7 +418,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -427,15 +438,13 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) } /// - /// Updates an existing ServiceDiagnosticSettingsResource. To update other - /// fields use the CreateOrUpdate method. **WARNING**: This method will be - /// deprecated in future releases. + /// Deletes existing diagnostic settings for the specified resource. /// /// /// The identifier of the resource. /// - /// - /// Parameters supplied to the operation. + /// + /// The name of the diagnostic setting. /// /// /// Headers that will be added to request. @@ -446,9 +455,6 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// Thrown when the operation returned an invalid status code /// - /// - /// Thrown when unable to deserialize the response - /// /// /// Thrown when a required parameter is null /// @@ -458,17 +464,17 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> UpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task DeleteWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceUri == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); } - if (serviceDiagnosticSettingsResource == null) + if (name == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "serviceDiagnosticSettingsResource"); + throw new ValidationException(ValidationRules.CannotBeNull, "name"); } - string apiVersion = "2016-09-01"; + string apiVersion = "2017-05-01-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -478,14 +484,15 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceUri", resourceUri); tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("serviceDiagnosticSettingsResource", serviceDiagnosticSettingsResource); + tracingParameters.Add("name", name); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings/service").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}").ToString(); _url = _url.Replace("{resourceUri}", System.Uri.EscapeDataString(resourceUri)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); List _queryParameters = new List(); if (apiVersion != null) { @@ -498,7 +505,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -529,12 +536,163 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) // Serialize Request string _requestContent = null; - if(serviceDiagnosticSettingsResource != null) + // Set Credentials + if (Client.Credentials != null) { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(serviceDiagnosticSettingsResource, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.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 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the active diagnostic settings list for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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> ListWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/diagnosticSettings").ToString(); + _url = _url.Replace("{resourceUri}", System.Uri.EscapeDataString(resourceUri)); + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.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 (Client.Credentials != null) { @@ -585,7 +743,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -598,7 +756,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsOperationsExtensions.cs new file mode 100644 index 000000000000..d1285d0e90a5 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/DiagnosticSettingsOperationsExtensions.cs @@ -0,0 +1,183 @@ +// 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.Monitor.Management +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DiagnosticSettingsOperations. + /// + public static partial class DiagnosticSettingsOperationsExtensions + { + /// + /// Gets the active diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + public static DiagnosticSettingsResource Get(this IDiagnosticSettingsOperations operations, string resourceUri, string name) + { + return operations.GetAsync(resourceUri, name).GetAwaiter().GetResult(); + } + + /// + /// Gets the active diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDiagnosticSettingsOperations operations, string resourceUri, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceUri, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The name of the diagnostic setting. + /// + public static DiagnosticSettingsResource CreateOrUpdate(this IDiagnosticSettingsOperations operations, string resourceUri, DiagnosticSettingsResource parameters, string name) + { + return operations.CreateOrUpdateAsync(resourceUri, parameters, name).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDiagnosticSettingsOperations operations, string resourceUri, DiagnosticSettingsResource parameters, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceUri, parameters, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes existing diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + public static void Delete(this IDiagnosticSettingsOperations operations, string resourceUri, string name) + { + operations.DeleteAsync(resourceUri, name).GetAwaiter().GetResult(); + } + + /// + /// Deletes existing diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDiagnosticSettingsOperations operations, string resourceUri, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceUri, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the active diagnostic settings list for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + public static DiagnosticSettingsResourceCollection List(this IDiagnosticSettingsOperations operations, string resourceUri) + { + return operations.ListAsync(resourceUri).GetAwaiter().GetResult(); + } + + /// + /// Gets the active diagnostic settings list for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IDiagnosticSettingsOperations operations, string resourceUri, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs index 7955c38f906d..ec5a2017b02d 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs @@ -42,7 +42,7 @@ public partial interface IActionGroupsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -67,7 +67,7 @@ public partial interface IActionGroupsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -92,7 +92,7 @@ public partial interface IActionGroupsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -108,7 +108,7 @@ public partial interface IActionGroupsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -130,7 +130,7 @@ public partial interface IActionGroupsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -159,7 +159,7 @@ public partial interface IActionGroupsOperations /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IDiagnosticSettingsCategoryOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IDiagnosticSettingsCategoryOperations.cs new file mode 100644 index 000000000000..3956c99adc31 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IDiagnosticSettingsCategoryOperations.cs @@ -0,0 +1,76 @@ +// 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.Monitor.Management +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DiagnosticSettingsCategoryOperations operations. + /// + public partial interface IDiagnosticSettingsCategoryOperations + { + /// + /// Gets the diagnostic settings category for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the diagnostic settings categories for the specified + /// resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The 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 + /// + Task> ListWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IDiagnosticSettingsOperations.cs similarity index 58% rename from src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs rename to src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IDiagnosticSettingsOperations.cs index 06d771b34732..6090f49a0573 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IDiagnosticSettingsOperations.cs @@ -20,17 +20,19 @@ namespace Microsoft.Azure.Management.Monitor.Management using System.Threading.Tasks; /// - /// ServiceDiagnosticSettingsOperations operations. + /// DiagnosticSettingsOperations operations. /// - public partial interface IServiceDiagnosticSettingsOperations + public partial interface IDiagnosticSettingsOperations { /// /// Gets the active diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. /// /// /// The identifier of the resource. /// + /// + /// The name of the diagnostic setting. + /// /// /// The headers that will be added to request. /// @@ -46,11 +48,9 @@ public partial interface IServiceDiagnosticSettingsOperations /// /// Thrown when a required parameter is null /// - Task> GetWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Create or update new diagnostic settings for the specified - /// resource. **WARNING**: This method will be deprecated in future - /// releases. + /// Creates or updates diagnostic settings for the specified resource. /// /// /// The identifier of the resource. @@ -58,13 +58,16 @@ public partial interface IServiceDiagnosticSettingsOperations /// /// Parameters supplied to the operation. /// + /// + /// The name of the diagnostic setting. + /// /// /// The headers that will be added to request. /// /// /// The cancellation token. /// - /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -73,17 +76,35 @@ public partial interface IServiceDiagnosticSettingsOperations /// /// Thrown when a required parameter is null /// - Task> CreateOrUpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceUri, DiagnosticSettingsResource parameters, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Updates an existing ServiceDiagnosticSettingsResource. To update - /// other fields use the CreateOrUpdate method. **WARNING**: This - /// method will be deprecated in future releases. + /// Deletes existing diagnostic settings for the specified resource. /// /// /// The identifier of the resource. /// - /// - /// Parameters supplied to the operation. + /// + /// The name of the diagnostic setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the active diagnostic settings list for the specified + /// resource. + /// + /// + /// The identifier of the resource. /// /// /// The headers that will be added to request. @@ -100,6 +121,6 @@ public partial interface IServiceDiagnosticSettingsOperations /// /// Thrown when a required parameter is null /// - Task> UpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> ListWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IMonitorManagementClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IMonitorManagementClient.cs index d62aaa694188..4dd3e9688878 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IMonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IMonitorManagementClient.cs @@ -85,9 +85,14 @@ public partial interface IMonitorManagementClient : System.IDisposable ILogProfilesOperations LogProfiles { get; } /// - /// Gets the IServiceDiagnosticSettingsOperations. + /// Gets the IDiagnosticSettingsOperations. /// - IServiceDiagnosticSettingsOperations ServiceDiagnosticSettings { get; } + IDiagnosticSettingsOperations DiagnosticSettings { get; } + + /// + /// Gets the IDiagnosticSettingsCategoryOperations. + /// + IDiagnosticSettingsCategoryOperations DiagnosticSettingsCategory { get; } /// /// Gets the IActionGroupsOperations. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActionGroupResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActionGroupResource.cs index e67be2ac5bd5..75a2a89ce48d 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActionGroupResource.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActionGroupResource.cs @@ -41,7 +41,7 @@ public ActionGroupResource() /// This will be used in SMS messages. /// Indicates whether this action group is /// enabled. If an action group is not enabled, then none of its - /// receviers will receive communications. + /// receivers will receive communications. /// Azure resource Id /// Azure resource name /// Azure resource type @@ -77,7 +77,7 @@ public ActionGroupResource() /// /// Gets or sets indicates whether this action group is enabled. If an - /// action group is not enabled, then none of its receviers will + /// action group is not enabled, then none of its receivers will /// receive communications. /// [JsonProperty(PropertyName = "properties.enabled")] diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertResource.cs index de21e07e2048..f230ff4f01fb 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertResource.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertResource.cs @@ -41,7 +41,7 @@ public ActivityLogAlertResource() /// prefixes. The alert will only apply to activityLogs with /// resourceIds that fall under one of these prefixes. This list must /// include at least one item. - /// The conditon that will cause this alert to + /// The condition that will cause this alert to /// activate. /// The actions that will activate when the /// condition is met. @@ -88,7 +88,7 @@ public ActivityLogAlertResource() public bool? Enabled { get; set; } /// - /// Gets or sets the conditon that will cause this alert to activate. + /// Gets or sets the condition that will cause this alert to activate. /// [JsonProperty(PropertyName = "properties.condition")] public ActivityLogAlertAllOfCondition Condition { get; set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsCategoryResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsCategoryResource.cs new file mode 100644 index 000000000000..f68084fd3551 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsCategoryResource.cs @@ -0,0 +1,78 @@ +// 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.Monitor.Management.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Azure.Management.Monitor.Management; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Description of diagnostic setting category. + /// + [Rest.Serialization.JsonTransformation] + public partial class DiagnosticSettingsCategoryResource : Resource + { + /// + /// Initializes a new instance of the + /// DiagnosticSettingsCategoryResource class. + /// + public DiagnosticSettingsCategoryResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DiagnosticSettingsCategoryResource class. + /// + /// Resource location + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// The type of the diagnostic settings + /// category. Can be 'Logs' or 'Metrics'. + public DiagnosticSettingsCategoryResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string categoryType = default(string)) + : base(location, id, name, type, tags) + { + CategoryType = categoryType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the diagnostic settings category. Can be + /// 'Logs' or 'Metrics'. + /// + [JsonProperty(PropertyName = "properties.categoryType")] + public string CategoryType { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsCategoryResourceCollection.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsCategoryResourceCollection.cs new file mode 100644 index 000000000000..3e373ec4948d --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsCategoryResourceCollection.cs @@ -0,0 +1,59 @@ +// 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.Monitor.Management.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Azure.Management.Monitor.Management; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a collection of diagnostic setting category resources. + /// + public partial class DiagnosticSettingsCategoryResourceCollection + { + /// + /// Initializes a new instance of the + /// DiagnosticSettingsCategoryResourceCollection class. + /// + public DiagnosticSettingsCategoryResourceCollection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DiagnosticSettingsCategoryResourceCollection class. + /// + /// The collection of diagnostic settings category + /// resources. + public DiagnosticSettingsCategoryResourceCollection(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the collection of diagnostic settings category + /// resources. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsResource.cs similarity index 74% rename from src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResource.cs rename to src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsResource.cs index f738bdb8c71d..4c7befb9dcb4 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResource.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsResource.cs @@ -20,23 +20,21 @@ namespace Microsoft.Azure.Management.Monitor.Management.Models using System.Linq; /// - /// Description of a service diagnostic setting + /// Description of diagnostic setting resource. /// [Rest.Serialization.JsonTransformation] - public partial class ServiceDiagnosticSettingsResource : Resource + public partial class DiagnosticSettingsResource : Resource { /// - /// Initializes a new instance of the ServiceDiagnosticSettingsResource - /// class. + /// Initializes a new instance of the DiagnosticSettingsResource class. /// - public ServiceDiagnosticSettingsResource() + public DiagnosticSettingsResource() { CustomInit(); } /// - /// Initializes a new instance of the ServiceDiagnosticSettingsResource - /// class. + /// Initializes a new instance of the DiagnosticSettingsResource class. /// /// Resource location /// Azure resource Id @@ -45,25 +43,22 @@ public ServiceDiagnosticSettingsResource() /// Resource tags /// The resource ID of the storage /// account to which you would like to send Diagnostic Logs. - /// The service bus rule ID of the - /// service bus namespace in which you would like to have Event Hubs - /// created for streaming Diagnostic Logs. The rule ID is of the - /// format: '{service bus resource ID}/authorizationrules/{key - /// name}'. /// The resource Id for the /// event hub authorization rule. + /// The name of the event hub. If none is + /// specified, the default event hub will be selected. /// the list of metric settings. /// the list of logs settings. /// The workspace ID (resource ID of a Log /// Analytics workspace) for a Log Analytics workspace to which you /// would like to send Diagnostic Logs. Example: /// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 - public ServiceDiagnosticSettingsResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string storageAccountId = default(string), string serviceBusRuleId = default(string), string eventHubAuthorizationRuleId = default(string), IList metrics = default(IList), IList logs = default(IList), string workspaceId = default(string)) + public DiagnosticSettingsResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string storageAccountId = default(string), string eventHubAuthorizationRuleId = default(string), string eventHubName = default(string), IList metrics = default(IList), IList logs = default(IList), string workspaceId = default(string)) : base(location, id, name, type, tags) { StorageAccountId = storageAccountId; - ServiceBusRuleId = serviceBusRuleId; EventHubAuthorizationRuleId = eventHubAuthorizationRuleId; + EventHubName = eventHubName; Metrics = metrics; Logs = logs; WorkspaceId = workspaceId; @@ -82,21 +77,19 @@ public ServiceDiagnosticSettingsResource() [JsonProperty(PropertyName = "properties.storageAccountId")] public string StorageAccountId { get; set; } - /// - /// Gets or sets the service bus rule ID of the service bus namespace - /// in which you would like to have Event Hubs created for streaming - /// Diagnostic Logs. The rule ID is of the format: '{service bus - /// resource ID}/authorizationrules/{key name}'. - /// - [JsonProperty(PropertyName = "properties.serviceBusRuleId")] - public string ServiceBusRuleId { get; set; } - /// /// Gets or sets the resource Id for the event hub authorization rule. /// [JsonProperty(PropertyName = "properties.eventHubAuthorizationRuleId")] public string EventHubAuthorizationRuleId { get; set; } + /// + /// Gets or sets the name of the event hub. If none is specified, the + /// default event hub will be selected. + /// + [JsonProperty(PropertyName = "properties.eventHubName")] + public string EventHubName { get; set; } + /// /// Gets or sets the list of metric settings. /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsResourceCollection.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsResourceCollection.cs new file mode 100644 index 000000000000..8d7385273d7f --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/DiagnosticSettingsResourceCollection.cs @@ -0,0 +1,58 @@ +// 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.Monitor.Management.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.Monitor; + using Microsoft.Azure.Management.Monitor.Management; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a collection of alert rule resources. + /// + public partial class DiagnosticSettingsResourceCollection + { + /// + /// Initializes a new instance of the + /// DiagnosticSettingsResourceCollection class. + /// + public DiagnosticSettingsResourceCollection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DiagnosticSettingsResourceCollection class. + /// + /// The collection of diagnostic settings + /// resources;. + public DiagnosticSettingsResourceCollection(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the collection of diagnostic settings resources;. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EmailReceiver.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EmailReceiver.cs index 74ea59154c67..a523cdc29ee9 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EmailReceiver.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EmailReceiver.cs @@ -36,8 +36,8 @@ public EmailReceiver() /// unique across all receivers within an action group. /// The email address of this /// receiver. - /// Possible values include: 'NotSpecified', - /// 'Enabled', 'Disabled' + /// The receiver status of the e-mail. Possible + /// values include: 'NotSpecified', 'Enabled', 'Disabled' public EmailReceiver(string name, string emailAddress, ReceiverStatus? status = default(ReceiverStatus?)) { Name = name; @@ -65,7 +65,8 @@ public EmailReceiver() public string EmailAddress { get; set; } /// - /// Gets possible values include: 'NotSpecified', 'Enabled', 'Disabled' + /// Gets the receiver status of the e-mail. Possible values include: + /// 'NotSpecified', 'Enabled', 'Disabled' /// [JsonProperty(PropertyName = "status")] public ReceiverStatus? Status { get; private set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/MetricSettings.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/MetricSettings.cs index f874dd9cdb03..d07507c0c4f7 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/MetricSettings.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/MetricSettings.cs @@ -32,15 +32,20 @@ public MetricSettings() /// /// Initializes a new instance of the MetricSettings class. /// + /// a value indicating whether this category is + /// enabled. /// the timegrain of the metric in ISO8601 /// format. - /// a value indicating whether this timegrain is - /// enabled. + /// Name of a Diagnostic Metric category for a + /// resource type this setting is applied to. To obtain the list of + /// Diagnostic metric categories for a resource, first perform a GET + /// diagnostic settings operation. /// the retention policy for this - /// timegrain. - public MetricSettings(System.TimeSpan timeGrain, bool enabled, RetentionPolicy retentionPolicy = default(RetentionPolicy)) + /// category. + public MetricSettings(bool enabled, System.TimeSpan? timeGrain = default(System.TimeSpan?), string category = default(string), RetentionPolicy retentionPolicy = default(RetentionPolicy)) { TimeGrain = timeGrain; + Category = category; Enabled = enabled; RetentionPolicy = retentionPolicy; CustomInit(); @@ -55,16 +60,25 @@ public MetricSettings() /// Gets or sets the timegrain of the metric in ISO8601 format. /// [JsonProperty(PropertyName = "timeGrain")] - public System.TimeSpan TimeGrain { get; set; } + public System.TimeSpan? TimeGrain { get; set; } + + /// + /// Gets or sets name of a Diagnostic Metric category for a resource + /// type this setting is applied to. To obtain the list of Diagnostic + /// metric categories for a resource, first perform a GET diagnostic + /// settings operation. + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } /// - /// Gets or sets a value indicating whether this timegrain is enabled. + /// Gets or sets a value indicating whether this category is enabled. /// [JsonProperty(PropertyName = "enabled")] public bool Enabled { get; set; } /// - /// Gets or sets the retention policy for this timegrain. + /// Gets or sets the retention policy for this category. /// [JsonProperty(PropertyName = "retentionPolicy")] public RetentionPolicy RetentionPolicy { get; set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResourcePatch.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResourcePatch.cs deleted file mode 100644 index 0d73d18e2459..000000000000 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResourcePatch.cs +++ /dev/null @@ -1,124 +0,0 @@ -// 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.Monitor.Management.Models -{ - using Microsoft.Azure; - using Microsoft.Azure.Management; - using Microsoft.Azure.Management.Monitor; - using Microsoft.Azure.Management.Monitor.Management; - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Service diagnostic setting resource for patch operations - /// - [Rest.Serialization.JsonTransformation] - public partial class ServiceDiagnosticSettingsResourcePatch - { - /// - /// Initializes a new instance of the - /// ServiceDiagnosticSettingsResourcePatch class. - /// - public ServiceDiagnosticSettingsResourcePatch() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// ServiceDiagnosticSettingsResourcePatch class. - /// - /// Resource tags - /// The resource ID of the storage - /// account to which you would like to send Diagnostic Logs. - /// The service bus rule ID of the - /// service bus namespace in which you would like to have Event Hubs - /// created for streaming Diagnostic Logs. The rule ID is of the - /// format: '{service bus resource ID}/authorizationrules/{key - /// name}'. - /// The resource Id for the - /// event hub authorization rule. - /// the list of metric settings. - /// the list of logs settings. - /// The workspace ID (resource ID of a Log - /// Analytics workspace) for a Log Analytics workspace to which you - /// would like to send Diagnostic Logs. Example: - /// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 - public ServiceDiagnosticSettingsResourcePatch(IDictionary tags = default(IDictionary), string storageAccountId = default(string), string serviceBusRuleId = default(string), string eventHubAuthorizationRuleId = default(string), IList metrics = default(IList), IList logs = default(IList), string workspaceId = default(string)) - { - Tags = tags; - StorageAccountId = storageAccountId; - ServiceBusRuleId = serviceBusRuleId; - EventHubAuthorizationRuleId = eventHubAuthorizationRuleId; - Metrics = metrics; - Logs = logs; - WorkspaceId = workspaceId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resource tags - /// - [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; set; } - - /// - /// Gets or sets the resource ID of the storage account to which you - /// would like to send Diagnostic Logs. - /// - [JsonProperty(PropertyName = "properties.storageAccountId")] - public string StorageAccountId { get; set; } - - /// - /// Gets or sets the service bus rule ID of the service bus namespace - /// in which you would like to have Event Hubs created for streaming - /// Diagnostic Logs. The rule ID is of the format: '{service bus - /// resource ID}/authorizationrules/{key name}'. - /// - [JsonProperty(PropertyName = "properties.serviceBusRuleId")] - public string ServiceBusRuleId { get; set; } - - /// - /// Gets or sets the resource Id for the event hub authorization rule. - /// - [JsonProperty(PropertyName = "properties.eventHubAuthorizationRuleId")] - public string EventHubAuthorizationRuleId { get; set; } - - /// - /// Gets or sets the list of metric settings. - /// - [JsonProperty(PropertyName = "properties.metrics")] - public IList Metrics { get; set; } - - /// - /// Gets or sets the list of logs settings. - /// - [JsonProperty(PropertyName = "properties.logs")] - public IList Logs { get; set; } - - /// - /// Gets or sets the workspace ID (resource ID of a Log Analytics - /// workspace) for a Log Analytics workspace to which you would like to - /// send Diagnostic Logs. Example: - /// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 - /// - [JsonProperty(PropertyName = "properties.workspaceId")] - public string WorkspaceId { get; set; } - - } -} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/SmsReceiver.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/SmsReceiver.cs index d75b7ecea194..af6aa9b82b78 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/SmsReceiver.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/SmsReceiver.cs @@ -38,8 +38,8 @@ public SmsReceiver() /// receiver. /// The phone number of the SMS /// receiver. - /// Possible values include: 'NotSpecified', - /// 'Enabled', 'Disabled' + /// The status of the receiver. Possible values + /// include: 'NotSpecified', 'Enabled', 'Disabled' public SmsReceiver(string name, string countryCode, string phoneNumber, ReceiverStatus? status = default(ReceiverStatus?)) { Name = name; @@ -74,7 +74,8 @@ public SmsReceiver() public string PhoneNumber { get; set; } /// - /// Gets possible values include: 'NotSpecified', 'Enabled', 'Disabled' + /// Gets the status of the receiver. Possible values include: + /// 'NotSpecified', 'Enabled', 'Disabled' /// [JsonProperty(PropertyName = "status")] public ReceiverStatus? Status { get; private set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/MonitorManagementClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/MonitorManagementClient.cs index 0e7e433eb24b..5c95542dbcb4 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/MonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/MonitorManagementClient.cs @@ -90,9 +90,14 @@ public partial class MonitorManagementClient : ServiceClient - /// Gets the IServiceDiagnosticSettingsOperations. + /// Gets the IDiagnosticSettingsOperations. /// - public virtual IServiceDiagnosticSettingsOperations ServiceDiagnosticSettings { get; private set; } + public virtual IDiagnosticSettingsOperations DiagnosticSettings { get; private set; } + + /// + /// Gets the IDiagnosticSettingsCategoryOperations. + /// + public virtual IDiagnosticSettingsCategoryOperations DiagnosticSettingsCategory { get; private set; } /// /// Gets the IActionGroupsOperations. @@ -309,7 +314,8 @@ private void Initialize() AlertRuleIncidents = new AlertRuleIncidentsOperations(this); AlertRules = new AlertRulesOperations(this); LogProfiles = new LogProfilesOperations(this); - ServiceDiagnosticSettings = new ServiceDiagnosticSettingsOperations(this); + DiagnosticSettings = new DiagnosticSettingsOperations(this); + DiagnosticSettingsCategory = new DiagnosticSettingsCategoryOperations(this); ActionGroups = new ActionGroupsOperations(this); ActivityLogAlerts = new ActivityLogAlertsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs deleted file mode 100644 index baab2bfa487e..000000000000 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs +++ /dev/null @@ -1,148 +0,0 @@ -// 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.Monitor.Management -{ - using Microsoft.Azure; - using Microsoft.Azure.Management; - using Microsoft.Azure.Management.Monitor; - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ServiceDiagnosticSettingsOperations. - /// - public static partial class ServiceDiagnosticSettingsOperationsExtensions - { - /// - /// Gets the active diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The identifier of the resource. - /// - public static ServiceDiagnosticSettingsResource Get(this IServiceDiagnosticSettingsOperations operations, string resourceUri) - { - return operations.GetAsync(resourceUri).GetAwaiter().GetResult(); - } - - /// - /// Gets the active diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The identifier of the resource. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IServiceDiagnosticSettingsOperations operations, string resourceUri, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceUri, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Create or update new diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The identifier of the resource. - /// - /// - /// Parameters supplied to the operation. - /// - public static ServiceDiagnosticSettingsResource CreateOrUpdate(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResource parameters) - { - return operations.CreateOrUpdateAsync(resourceUri, parameters).GetAwaiter().GetResult(); - } - - /// - /// Create or update new diagnostic settings for the specified resource. - /// **WARNING**: This method will be deprecated in future releases. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The identifier of the resource. - /// - /// - /// Parameters supplied to the operation. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResource parameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceUri, parameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Updates an existing ServiceDiagnosticSettingsResource. To update other - /// fields use the CreateOrUpdate method. **WARNING**: This method will be - /// deprecated in future releases. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The identifier of the resource. - /// - /// - /// Parameters supplied to the operation. - /// - public static ServiceDiagnosticSettingsResource Update(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource) - { - return operations.UpdateAsync(resourceUri, serviceDiagnosticSettingsResource).GetAwaiter().GetResult(); - } - - /// - /// Updates an existing ServiceDiagnosticSettingsResource. To update other - /// fields use the CreateOrUpdate method. **WARNING**: This method will be - /// deprecated in future releases. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The identifier of the resource. - /// - /// - /// Parameters supplied to the operation. - /// - /// - /// The cancellation token. - /// - public static async Task UpdateAsync(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceUri, serviceDiagnosticSettingsResource, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj b/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj index 9768403b35ca..0044f1d45e53 100644 --- a/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj +++ b/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj @@ -3,12 +3,14 @@ Microsoft Azure Monitor Library Microsoft.Azure.Management.Monitor - 0.16.1-preview + 0.17.0-preview Microsoft.Azure.Management.Monitor Management.Monitor;Management.Monitoring;metrics;alerts;autoscale;activityLogs;events;operations;logs net452;netstandard1.4 Microsoft.Azure.Management.Monitor + false + false diff --git a/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs b/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs index 8ac46bc0d8c0..03a250a46b08 100644 --- a/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs +++ b/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ [assembly: AssemblyTitle("Microsoft Azure Monitor Library")] [assembly: AssemblyDescription("Provides Microsoft Azure Monitor operations.")] -[assembly: AssemblyVersion("0.16.1.0")] -[assembly: AssemblyFileVersion("0.16.1.0")] +[assembly: AssemblyVersion("0.17.0.0")] +[assembly: AssemblyFileVersion("0.17.0.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Microsoft Azure .NET SDK")] diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/DiagnosticSettingsTests.cs similarity index 80% rename from src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs rename to src/SDKs/Monitor/Monitor.Tests/BasicTests/DiagnosticSettingsTests.cs index b45ebb4de2e8..834cea08d1c6 100644 --- a/src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/DiagnosticSettingsTests.cs @@ -12,13 +12,13 @@ namespace Monitor.Tests.BasicTests { - public class ServiceDiagnosticSettingsTests : TestBase + public class DiagnosticSettingsTests : TestBase { private const string ResourceUri = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.web/serverFarms/DefaultServerFarm"; [Fact] [Trait("Category", "Mock")] - public void ServiceDiagnosticSettings_PutTest() + public void DiagnosticSettings_PutTest() { var expResponse = CreateDiagnosticSettings(); var handler = new RecordedDelegatingHandler(); @@ -34,13 +34,16 @@ public void ServiceDiagnosticSettings_PutTest() var parameters = CreateDiagnosticSettingsParams(); - ServiceDiagnosticSettingsResource response = insightsClient.ServiceDiagnosticSettings.CreateOrUpdate(resourceUri: ResourceUri, parameters: parameters); + DiagnosticSettingsResource response = insightsClient.DiagnosticSettings.CreateOrUpdate( + resourceUri: ResourceUri, + parameters: parameters, + name: "service"); AreEqual(expResponse, response); } [Fact] [Trait("Category", "Mock")] - public void ServiceDiagnosticSettings_UpdateTest() + public void DiagnosticSettings_UpdateTest() { var resource = CreateDiagnosticSettings(); var handler = new RecordedDelegatingHandler(); @@ -54,23 +57,26 @@ public void ServiceDiagnosticSettings_UpdateTest() handler = new RecordedDelegatingHandler(expectedResponse); monitorManagementClient = GetMonitorManagementClient(handler); - ServiceDiagnosticSettingsResourcePatch patchResource = new ServiceDiagnosticSettingsResourcePatch( + DiagnosticSettingsResource patchResource = new DiagnosticSettingsResource( tags: resource.Tags, storageAccountId: resource.StorageAccountId, - serviceBusRuleId: resource.ServiceBusRuleId, eventHubAuthorizationRuleId: resource.EventHubAuthorizationRuleId, metrics: resource.Metrics, logs: resource.Logs, - workspaceId: resource.WorkspaceId + workspaceId: resource.WorkspaceId, + location: "eastus" ); - ServiceDiagnosticSettingsResource response = monitorManagementClient.ServiceDiagnosticSettings.Update(resourceUri: ResourceUri, serviceDiagnosticSettingsResource: patchResource); + DiagnosticSettingsResource response = monitorManagementClient.DiagnosticSettings.CreateOrUpdate( + resourceUri: ResourceUri, + parameters: patchResource, + name: "service"); AreEqual(resource, response); } [Fact] [Trait("Category", "Mock")] - public void ServiceDiagnosticSettings_GetTest() + public void DiagnosticSettings_GetTest() { var expResponse = CreateDiagnosticSettings(); var handler = new RecordedDelegatingHandler(); @@ -84,16 +90,16 @@ public void ServiceDiagnosticSettings_GetTest() handler = new RecordedDelegatingHandler(expectedResponse); insightsClient = GetMonitorManagementClient(handler); - ServiceDiagnosticSettingsResource actualResponse = insightsClient.ServiceDiagnosticSettings.Get(resourceUri: ResourceUri); + DiagnosticSettingsResource actualResponse = insightsClient.DiagnosticSettings.Get(resourceUri: ResourceUri, name: "service"); AreEqual(expResponse, actualResponse); } - private static ServiceDiagnosticSettingsResource CreateDiagnosticSettingsParams() + private static DiagnosticSettingsResource CreateDiagnosticSettingsParams() { - return new ServiceDiagnosticSettingsResource + return new DiagnosticSettingsResource { StorageAccountId = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.storage/storageaccounts/sa1", - ServiceBusRuleId = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.servicebus/namespaces/ns1/authorizationRules/authrule", + EventHubAuthorizationRuleId = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.servicebus/namespaces/ns1/authorizationRules/authrule", WorkspaceId = "wsId", Logs = new List { @@ -123,12 +129,12 @@ private static ServiceDiagnosticSettingsResource CreateDiagnosticSettingsParams( }; } - private static ServiceDiagnosticSettingsResource CreateDiagnosticSettings() + private static DiagnosticSettingsResource CreateDiagnosticSettings() { - return new ServiceDiagnosticSettingsResource + return new DiagnosticSettingsResource { StorageAccountId = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.storage/storageaccounts/sa1", - ServiceBusRuleId = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.servicebus/namespaces/ns1/authorizationRules/authrule", + EventHubAuthorizationRuleId = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.servicebus/namespaces/ns1/authorizationRules/authrule", WorkspaceId = "wsId", Logs = new List { @@ -157,7 +163,7 @@ private static ServiceDiagnosticSettingsResource CreateDiagnosticSettings() }; } - private static void AreEqual(ServiceDiagnosticSettingsResource exp, ServiceDiagnosticSettingsResource act) + private static void AreEqual(DiagnosticSettingsResource exp, DiagnosticSettingsResource act) { if (exp == act) { @@ -176,7 +182,7 @@ private static void AreEqual(ServiceDiagnosticSettingsResource exp, ServiceDiagn Assert.Equal(exp.StorageAccountId, act.StorageAccountId); Assert.Equal(exp.WorkspaceId, act.WorkspaceId); - Assert.Equal(exp.ServiceBusRuleId, act.ServiceBusRuleId); + Assert.Equal(exp.EventHubAuthorizationRuleId, act.EventHubAuthorizationRuleId); } private static void Compare(T exp, T act) diff --git a/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs b/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs index e037674b0f55..45e99a64ce36 100644 --- a/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs +++ b/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs @@ -562,7 +562,7 @@ private static void CompareListString(IList exp, IList act) #endregion #region ServiceDiagnosticsSettings - public static void AreEqual(ServiceDiagnosticSettingsResource exp, ServiceDiagnosticSettingsResource act) + public static void AreEqual(DiagnosticSettingsResource exp, DiagnosticSettingsResource act) { if (exp == act) { @@ -581,7 +581,7 @@ public static void AreEqual(ServiceDiagnosticSettingsResource exp, ServiceDiagno Assert.Equal(exp.StorageAccountId, act.StorageAccountId); Assert.Equal(exp.WorkspaceId, act.WorkspaceId); - Assert.Equal(exp.ServiceBusRuleId, act.ServiceBusRuleId); + Assert.Equal(exp.EventHubAuthorizationRuleId, act.EventHubAuthorizationRuleId); } private static void Compare(T exp, T act) diff --git a/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj b/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj index ccfe37690283..795e8219f4a1 100644 --- a/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj +++ b/src/SDKs/Monitor/Monitor.Tests/Monitor.Tests.csproj @@ -7,7 +7,7 @@ 1.0.0-preview - net452;netcoreapp1.1 + net452;netcoreapp1.1 @@ -27,7 +27,7 @@ - + diff --git a/src/SDKs/Monitor/Monitor.Tests/Scenarios/DiagnosticSettingsTests.cs b/src/SDKs/Monitor/Monitor.Tests/Scenarios/DiagnosticSettingsTests.cs new file mode 100644 index 000000000000..53f22adb96cf --- /dev/null +++ b/src/SDKs/Monitor/Monitor.Tests/Scenarios/DiagnosticSettingsTests.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Net; +using Monitor.Tests.Helpers; +using Microsoft.Azure.Management.Monitor.Management; +using Microsoft.Azure.Management.Monitor.Management.Models; +using Xunit; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + +namespace Monitor.Tests.Scenarios +{ + public class DiagnosticSettingsTests : TestBase + { + //private const string ResourceUri = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.web/serverFarms/DefaultServerFarm"; + private const string ResourceUri = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/alertruleTest"; + private RecordedDelegatingHandler handler; + + public DiagnosticSettingsTests() + : base() + { + handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; + } + + + /// + /// User needs several permissions before executing these commands. Otherwise it fails for some authorization issue. + /// + [Fact] + [Trait("Category", "Scenario")] + public void CreateGetUpdateDiagnosticSetting() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + var insightsClient = GetMonitorManagementClient(context, handler); + + var parameters = CreateDiagnosticSettings(); + + DiagnosticSettingsResource response = insightsClient.DiagnosticSettings.CreateOrUpdate( + resourceUri: ResourceUri, + parameters: parameters, + name: "service"); + + if (!this.IsRecording) + { + Check(response, parameters); + } + + DiagnosticSettingsResource actual = insightsClient.DiagnosticSettings.Get(resourceUri: ResourceUri, name: "service"); + + if (!this.IsRecording) + { + Check(actual, parameters); + + Utilities.AreEqual(response, actual); + } + } + } + + private static DiagnosticSettingsResource CreateDiagnosticSettings() + { + return new DiagnosticSettingsResource + { + EventHubAuthorizationRuleId = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.servicebus/namespaces/serblp1/authorizationrules/ar1", + EventHubName = "myeventhub", + StorageAccountId = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-westus/providers/microsoft.storage/storageaccounts/salp1", + WorkspaceId = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.operationalinsights/workspaces/myworkspace", + Logs = new List + { + new LogSettings + { + RetentionPolicy = new RetentionPolicy + { + Days = 90, + Enabled = true + } + } + }, + Metrics = new List + { + new MetricSettings + { + Enabled = true, + RetentionPolicy = new RetentionPolicy + { + Enabled = true, + Days = 90 + }, + TimeGrain = TimeSpan.FromMinutes(1) + } + }, + Location = string.Empty + }; + } + + private static void Check(DiagnosticSettingsResource expected, DiagnosticSettingsResource actual) + { + Assert.Equal(expected.StorageAccountId, actual.StorageAccountId); + Assert.Equal(expected.EventHubAuthorizationRuleId, actual.EventHubAuthorizationRuleId); + Assert.Equal(expected.EventHubName, actual.EventHubName); + Assert.Equal(expected.WorkspaceId, actual.WorkspaceId); + } + } +} + diff --git a/src/SDKs/Monitor/Monitor.Tests/Scenarios/ServiceDiagnosticSettingsTests.cs b/src/SDKs/Monitor/Monitor.Tests/Scenarios/ServiceDiagnosticSettingsTests.cs deleted file mode 100644 index 39fccd154202..000000000000 --- a/src/SDKs/Monitor/Monitor.Tests/Scenarios/ServiceDiagnosticSettingsTests.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Net; -using Monitor.Tests.Helpers; -using Microsoft.Azure.Management.Monitor.Management; -using Microsoft.Azure.Management.Monitor.Management.Models; -using Xunit; -using Microsoft.Rest.ClientRuntime.Azure.TestFramework; - -namespace Monitor.Tests.Scenarios -{ - public class ServiceDiagnosticSettingsTests : TestBase - { - //private const string ResourceUri = "/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.web/serverFarms/DefaultServerFarm"; - private const string ResourceUri = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/alertruleTest"; - private RecordedDelegatingHandler handler; - - public ServiceDiagnosticSettingsTests() - : base() - { - handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; - } - - - /// - /// User needs several permissions before executing these commands. Otherwise it fails for some authorization issue. - /// - [Fact] - [Trait("Category", "Scenario")] - public void CreateGetUpdateServiceDiagnosticSetting() - { - using (MockContext context = MockContext.Start(this.GetType().FullName)) - { - var expResponse = CreateDiagnosticSettings(); - var insightsClient = GetMonitorManagementClient(context, handler); - - var parameters = CreateDiagnosticSettingsParams(); - - ServiceDiagnosticSettingsResource response = insightsClient.ServiceDiagnosticSettings.CreateOrUpdate( - resourceUri: ResourceUri, - parameters: parameters); - - if (!this.IsRecording) - { - Check(response); - - // AreEqual(expResponse, response); - } - - ServiceDiagnosticSettingsResource actualResponse = insightsClient.ServiceDiagnosticSettings.Get(resourceUri: ResourceUri); - - if (!this.IsRecording) - { - Check(actualResponse); - - Utilities.AreEqual(response, actualResponse); - } - - ServiceDiagnosticSettingsResourcePatch patchResource = new ServiceDiagnosticSettingsResourcePatch( - tags: response.Tags, - storageAccountId: response.StorageAccountId, - serviceBusRuleId: response.ServiceBusRuleId, - eventHubAuthorizationRuleId: response.EventHubAuthorizationRuleId, - metrics: response.Metrics, - logs: response.Logs, - workspaceId: response.WorkspaceId - ); - - patchResource.Metrics[0].RetentionPolicy.Days = 10; - patchResource.Metrics[0].RetentionPolicy.Enabled = true; - patchResource.Metrics[0].Enabled = true; - - patchResource.Logs = new List - { - new LogSettings - { - RetentionPolicy = new RetentionPolicy - { - Days = 5, - Enabled = true - } - } - }; - - // TODO: fails with message: 'Category' is not supported - ServiceDiagnosticSettingsResource patchResponse = null; - - Assert.Throws( - () => patchResponse = insightsClient.ServiceDiagnosticSettings.Update( - resourceUri: ResourceUri, - serviceDiagnosticSettingsResource: patchResource)); - - if (!this.IsRecording && patchResponse != null) - { - Check(patchResponse); - - Assert.Equal(actualResponse.Id, patchResponse.Id); - Assert.NotNull(patchResponse.Logs); - Assert.True(patchResource.Metrics[0].Enabled); - } - } - } - - private static ServiceDiagnosticSettingsResource CreateDiagnosticSettingsParams() - { - return new ServiceDiagnosticSettingsResource - { - EventHubAuthorizationRuleId = null, - StorageAccountId = null, // "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-westus/providers/microsoft.storage/storageaccounts/salp1", - ServiceBusRuleId = null, // "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.servicebus/namespaces/serblp1/authorizationrules/ar1", - WorkspaceId = null, // "providers/microsoft.storage", - Logs = new List(), - Metrics = new List - { - new MetricSettings - { - Enabled = false, - RetentionPolicy = new RetentionPolicy - { - Enabled = false, - Days = 0 - }, - TimeGrain = TimeSpan.FromMinutes(1) - } - }, - Location = string.Empty - }; - } - - private static ServiceDiagnosticSettingsResource CreateDiagnosticSettings() - { - return new ServiceDiagnosticSettingsResource - { - StorageAccountId = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-westus/providers/microsoft.storage/storageaccounts/salp1", - //ServiceBusRuleId = "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.servicebus/namespaces/serblp1/authorizationrules/ar1", - WorkspaceId = "providers/microsoft.storage", - Logs = new List - { - new LogSettings - { - RetentionPolicy = new RetentionPolicy - { - Days = 90, - Enabled = true - } - } - }, - Metrics = new List - { - new MetricSettings - { - Enabled = true, - RetentionPolicy = new RetentionPolicy - { - Enabled = true, - Days = 90 - }, - TimeGrain = TimeSpan.FromMinutes(1) - } - } - }; - } - - private static void Check(ServiceDiagnosticSettingsResource act) - { - Assert.False(string.IsNullOrWhiteSpace(act.Name)); - Assert.False(string.IsNullOrWhiteSpace(act.Id)); - } - } -} diff --git a/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.ServiceDiagnosticSettingsTests/CreateGetUpdateServiceDiagnosticSetting.json b/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.DiagnosticSettingsTests/CreateGetUpdateDiagnosticSetting.json similarity index 53% rename from src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.ServiceDiagnosticSettingsTests/CreateGetUpdateServiceDiagnosticSetting.json rename to src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.DiagnosticSettingsTests/CreateGetUpdateDiagnosticSetting.json index 46f2497aafa7..77b35090338e 100644 --- a/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.ServiceDiagnosticSettingsTests/CreateGetUpdateServiceDiagnosticSetting.json +++ b/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.DiagnosticSettingsTests/CreateGetUpdateDiagnosticSetting.json @@ -1,10 +1,10 @@ { "Entries": [ { - "RequestUri": "/%2Fsubscriptions%2F07c0b09d-9f69-4e6e-8d05-f59f67299cb2%2FresourceGroups%2FRac46PostSwapRG%2Fproviders%2FMicrosoft.Web%2Fsites%2FalertruleTest/providers/microsoft.insights/diagnosticSettings/service?api-version=2016-09-01", - "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkYwN2MwYjA5ZC05ZjY5LTRlNmUtOGQwNS1mNTlmNjcyOTljYjIlMkZyZXNvdXJjZUdyb3VwcyUyRlJhYzQ2UG9zdFN3YXBSRyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5XZWIlMkZzaXRlcyUyRmFsZXJ0cnVsZVRlc3QvcHJvdmlkZXJzL21pY3Jvc29mdC5pbnNpZ2h0cy9kaWFnbm9zdGljU2V0dGluZ3Mvc2VydmljZT9hcGktdmVyc2lvbj0yMDE2LTA5LTAx", + "RequestUri": "/%2Fsubscriptions%2F07c0b09d-9f69-4e6e-8d05-f59f67299cb2%2FresourceGroups%2FRac46PostSwapRG%2Fproviders%2FMicrosoft.Web%2Fsites%2FalertruleTest/providers/microsoft.insights/diagnosticSettings/service?api-version=2017-05-01-preview", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkYwN2MwYjA5ZC05ZjY5LTRlNmUtOGQwNS1mNTlmNjcyOTljYjIlMkZyZXNvdXJjZUdyb3VwcyUyRlJhYzQ2UG9zdFN3YXBSRyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5XZWIlMkZzaXRlcyUyRmFsZXJ0cnVsZVRlc3QvcHJvdmlkZXJzL21pY3Jvc29mdC5pbnNpZ2h0cy9kaWFnbm9zdGljU2V0dGluZ3Mvc2VydmljZT9hcGktdmVyc2lvbj0yMDE3LTA1LTAxLXByZXZpZXc=", "RequestMethod": "PUT", - "RequestBody": "{\r\n \"properties\": {\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\",\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": false,\r\n \"days\": 0\r\n }\r\n }\r\n ],\r\n \"logs\": []\r\n },\r\n \"location\": \"\"\r\n}", + "RequestBody": "{\r\n \"properties\": {\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\", \"category\": \"AllMetrics\",\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": false,\r\n \"days\": 0\r\n }\r\n }\r\n ],\r\n \"logs\": []\r\n },\r\n \"location\": \"\"\r\n}", "RequestHeaders": { "Content-Type": [ "application/json; charset=utf-8" @@ -25,7 +25,7 @@ "Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.16.1.0" ] }, - "ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourcegroups/rac46postswaprg/providers/microsoft.web/sites/alertruletest/providers/microsoft.insights/diagnosticSettings/service\",\r\n \"type\": null,\r\n \"name\": \"service\",\r\n \"location\": null,\r\n \"kind\": null,\r\n \"tags\": null,\r\n \"properties\": {\r\n \"storageAccountId\": null,\r\n \"serviceBusRuleId\": null,\r\n \"workspaceId\": null,\r\n \"eventHubAuthorizationRuleId\": null,\r\n \"eventHubName\": null,\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\",\r\n \"category\": \"AllMetrics\",\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": false,\r\n \"days\": 0\r\n }\r\n }\r\n ],\r\n \"logs\": null\r\n },\r\n \"identity\": null\r\n}", + "ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourcegroups/rac46postswaprg/providers/microsoft.web/sites/alertruletest/providers/microsoft.insights/diagnosticSettings/service\",\r\n \"type\": null,\r\n \"name\": \"service\",\r\n \"location\": null,\r\n \"kind\": null,\r\n \"tags\": null,\r\n \"properties\": {\r\n \"storageAccountId\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-westus/providers/microsoft.storage/storageaccounts/salp1\",\r\n \"workspaceId\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.operationalinsights/workspaces/myworkspace\",\r\n \"eventHubAuthorizationRuleId\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.servicebus/namespaces/serblp1/authorizationrules/ar1\",\r\n \"eventHubName\": \"myeventhub\",\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\",\r\n \"category\": \"AllMetrics\",\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": false,\r\n \"days\": 0\r\n }\r\n }\r\n ],\r\n \"logs\": null\r\n },\r\n \"identity\": null\r\n}", "ResponseHeaders": { "Content-Length": [ "543" @@ -67,8 +67,8 @@ "StatusCode": 200 }, { - "RequestUri": "/%2Fsubscriptions%2F07c0b09d-9f69-4e6e-8d05-f59f67299cb2%2FresourceGroups%2FRac46PostSwapRG%2Fproviders%2FMicrosoft.Web%2Fsites%2FalertruleTest/providers/microsoft.insights/diagnosticSettings/service?api-version=2016-09-01", - "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkYwN2MwYjA5ZC05ZjY5LTRlNmUtOGQwNS1mNTlmNjcyOTljYjIlMkZyZXNvdXJjZUdyb3VwcyUyRlJhYzQ2UG9zdFN3YXBSRyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5XZWIlMkZzaXRlcyUyRmFsZXJ0cnVsZVRlc3QvcHJvdmlkZXJzL21pY3Jvc29mdC5pbnNpZ2h0cy9kaWFnbm9zdGljU2V0dGluZ3Mvc2VydmljZT9hcGktdmVyc2lvbj0yMDE2LTA5LTAx", + "RequestUri": "/%2Fsubscriptions%2F07c0b09d-9f69-4e6e-8d05-f59f67299cb2%2FresourceGroups%2FRac46PostSwapRG%2Fproviders%2FMicrosoft.Web%2Fsites%2FalertruleTest/providers/microsoft.insights/diagnosticSettings/service?api-version=2017-05-01-preview", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkYwN2MwYjA5ZC05ZjY5LTRlNmUtOGQwNS1mNTlmNjcyOTljYjIlMkZyZXNvdXJjZUdyb3VwcyUyRlJhYzQ2UG9zdFN3YXBSRyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5XZWIlMkZzaXRlcyUyRmFsZXJ0cnVsZVRlc3QvcHJvdmlkZXJzL21pY3Jvc29mdC5pbnNpZ2h0cy9kaWFnbm9zdGljU2V0dGluZ3Mvc2VydmljZT9hcGktdmVyc2lvbj0yMDE3LTA1LTAxLXByZXZpZXc=", "RequestMethod": "GET", "RequestBody": "", "RequestHeaders": { @@ -85,7 +85,7 @@ "Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.16.1.0" ] }, - "ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourcegroups/rac46postswaprg/providers/microsoft.web/sites/alertruletest/providers/microsoft.insights/diagnosticSettings/service\",\r\n \"type\": null,\r\n \"name\": \"service\",\r\n \"location\": null,\r\n \"kind\": null,\r\n \"tags\": null,\r\n \"properties\": {\r\n \"storageAccountId\": null,\r\n \"serviceBusRuleId\": null,\r\n \"workspaceId\": null,\r\n \"eventHubAuthorizationRuleId\": null,\r\n \"eventHubName\": null,\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\",\r\n \"category\": \"AllMetrics\",\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": false,\r\n \"days\": 0\r\n }\r\n }\r\n ],\r\n \"logs\": []\r\n },\r\n \"identity\": null\r\n}", + "ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourcegroups/rac46postswaprg/providers/microsoft.web/sites/alertruletest/providers/microsoft.insights/diagnosticSettings/service\",\r\n \"type\": null,\r\n \"name\": \"service\",\r\n \"location\": null,\r\n \"kind\": null,\r\n \"tags\": null,\r\n \"properties\": {\r\n \"storageAccountId\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-westus/providers/microsoft.storage/storageaccounts/salp1\",\r\n \"workspaceId\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.operationalinsights/workspaces/myworkspace\",\r\n \"eventHubAuthorizationRuleId\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default/providers/microsoft.servicebus/namespaces/serblp1/authorizationrules/ar1\",\r\n \"eventHubName\": \"myeventhub\",\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\",\r\n \"category\": \"AllMetrics\",\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": false,\r\n \"days\": 0\r\n }\r\n }\r\n ],\r\n \"logs\": []\r\n },\r\n \"identity\": null\r\n}", "ResponseHeaders": { "Content-Length": [ "541" @@ -125,72 +125,6 @@ ] }, "StatusCode": 200 - }, - { - "RequestUri": "/%2Fsubscriptions%2F07c0b09d-9f69-4e6e-8d05-f59f67299cb2%2FresourceGroups%2FRac46PostSwapRG%2Fproviders%2FMicrosoft.Web%2Fsites%2FalertruleTest/providers/microsoft.insights/diagnosticSettings/service?api-version=2016-09-01", - "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkYwN2MwYjA5ZC05ZjY5LTRlNmUtOGQwNS1mNTlmNjcyOTljYjIlMkZyZXNvdXJjZUdyb3VwcyUyRlJhYzQ2UG9zdFN3YXBSRyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5XZWIlMkZzaXRlcyUyRmFsZXJ0cnVsZVRlc3QvcHJvdmlkZXJzL21pY3Jvc29mdC5pbnNpZ2h0cy9kaWFnbm9zdGljU2V0dGluZ3Mvc2VydmljZT9hcGktdmVyc2lvbj0yMDE2LTA5LTAx", - "RequestMethod": "PATCH", - "RequestBody": "{\r\n \"properties\": {\r\n \"metrics\": [\r\n {\r\n \"timeGrain\": \"PT1M\",\r\n \"enabled\": true,\r\n \"retentionPolicy\": {\r\n \"enabled\": true,\r\n \"days\": 10\r\n }\r\n }\r\n ],\r\n \"logs\": [\r\n {\r\n \"enabled\": false,\r\n \"retentionPolicy\": {\r\n \"enabled\": true,\r\n \"days\": 5\r\n }\r\n }\r\n ]\r\n }\r\n}", - "RequestHeaders": { - "Content-Type": [ - "application/json; charset=utf-8" - ], - "Content-Length": [ - "376" - ], - "x-ms-client-request-id": [ - "57f86cfb-5bc9-40b5-8408-8ef563bd4ca5" - ], - "accept-language": [ - "en-US" - ], - "User-Agent": [ - "FxVersion/4.7.2053.0", - "OSName/WindowsServer2012R2Standard", - "OSVersion/6.3.9600", - "Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.16.1.0" - ] - }, - "ResponseBody": "{\r\n \"code\": \"BadRequest\",\r\n \"message\": \"Category '' is not supported.\"\r\n}", - "ResponseHeaders": { - "Content-Length": [ - "63" - ], - "Content-Type": [ - "application/json; charset=utf-8" - ], - "Expires": [ - "-1" - ], - "Pragma": [ - "no-cache" - ], - "Strict-Transport-Security": [ - "max-age=31536000; includeSubDomains" - ], - "x-ms-request-id": [ - "00000000-0000-0000-0000-000000000000" - ], - "x-ms-ratelimit-remaining-subscription-writes": [ - "1198" - ], - "x-ms-correlation-request-id": [ - "d0899486-a6aa-463f-a2f4-6fedc078b6af" - ], - "x-ms-routing-request-id": [ - "WESTUS2:20170809T191029Z:d0899486-a6aa-463f-a2f4-6fedc078b6af" - ], - "Cache-Control": [ - "no-cache" - ], - "Date": [ - "Wed, 09 Aug 2017 19:10:29 GMT" - ], - "Server": [ - "Microsoft-IIS/8.5" - ] - }, - "StatusCode": 400 } ], "Names": {},