diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs new file mode 100644 index 000000000000..dbbf72da5321 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperations.cs @@ -0,0 +1,1206 @@ +// 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 1.0.1.0 +// 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; + + /// + /// ActionGroupsOperations operations. + /// + internal partial class ActionGroupsOperations : IServiceOperations, IActionGroupsOperations + { + /// + /// Initializes a new instance of the ActionGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ActionGroupsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Create a new action group or update an existing one. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The action group to create or use for the update. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (actionGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "actionGroupName"); + } + if (actionGroup == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "actionGroup"); + } + if (actionGroup != null) + { + actionGroup.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("actionGroupName", actionGroupName); + tracingParameters.Add("actionGroup", actionGroup); + tracingParameters.Add("apiVersion", apiVersion); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{actionGroupName}", System.Uri.EscapeDataString(actionGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _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; + if(actionGroup != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(actionGroup, 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"); + } + // 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 && (int)_statusCode != 201) + { + var ex = new CloudException(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); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = 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); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _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; + } + + /// + /// Get an action group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// 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 resourceGroupName, string actionGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (actionGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "actionGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("actionGroupName", actionGroupName); + tracingParameters.Add("apiVersion", apiVersion); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{actionGroupName}", System.Uri.EscapeDataString(actionGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (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 && (int)_statusCode != 404) + { + var ex = new CloudException(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); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = 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; + } + + /// + /// Delete an action group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// 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 + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string actionGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (actionGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "actionGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("actionGroupName", actionGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{actionGroupName}", System.Uri.EscapeDataString(actionGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _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 && (int)_statusCode != 204) + { + var ex = new CloudException(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); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a list of all action groups in a subscription. + /// + /// + /// 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>> ListBySubscriptionIdWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionId", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (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 CloudException(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); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = 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; + } + + /// + /// Get a list of all action groups in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (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 CloudException(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); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = 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; + } + + /// + /// Enable a receiver in an action group. This changes the receiver's status + /// from Disabled to Enabled. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The name of the receiver to resubscribe. + /// + /// + /// 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 + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task EnableReceiverWithHttpMessagesAsync(string resourceGroupName, string actionGroupName, string receiverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (actionGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "actionGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (receiverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "receiverName"); + } + string apiVersion = "2017-04-01"; + EnableRequest enableRequest = new EnableRequest(); + if (receiverName != null) + { + enableRequest.ReceiverName = receiverName; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("actionGroupName", actionGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("enableRequest", enableRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "EnableReceiver", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{actionGroupName}", System.Uri.EscapeDataString(actionGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _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; + if(enableRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(enableRequest, 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"); + } + // 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 && (int)_statusCode != 409 && (int)_statusCode != 404) + { + var ex = new CloudException(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); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperationsExtensions.cs new file mode 100644 index 000000000000..c5256dee0a1c --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActionGroupsOperationsExtensions.cs @@ -0,0 +1,258 @@ +// 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 1.0.1.0 +// 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; + + /// + /// Extension methods for ActionGroupsOperations. + /// + public static partial class ActionGroupsOperationsExtensions + { + /// + /// Create a new action group or update an existing one. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The action group to create or use for the update. + /// + public static ActionGroupResource CreateOrUpdate(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup) + { + return operations.CreateOrUpdateAsync(resourceGroupName, actionGroupName, actionGroup).GetAwaiter().GetResult(); + } + + /// + /// Create a new action group or update an existing one. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The action group to create or use for the update. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, actionGroupName, actionGroup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get an action group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + public static ActionGroupResource Get(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName) + { + return operations.GetAsync(resourceGroupName, actionGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get an action group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, actionGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an action group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + public static void Delete(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName) + { + operations.DeleteAsync(resourceGroupName, actionGroupName).GetAwaiter().GetResult(); + } + + /// + /// Delete an action group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, actionGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get a list of all action groups in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscriptionId(this IActionGroupsOperations operations) + { + return operations.ListBySubscriptionIdAsync().GetAwaiter().GetResult(); + } + + /// + /// Get a list of all action groups in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionIdAsync(this IActionGroupsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionIdWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a list of all action groups in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + public static IEnumerable ListByResourceGroup(this IActionGroupsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get a list of all action groups in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IActionGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Enable a receiver in an action group. This changes the receiver's status + /// from Disabled to Enabled. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The name of the receiver to resubscribe. + /// + public static void EnableReceiver(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, string receiverName) + { + operations.EnableReceiverAsync(resourceGroupName, actionGroupName, receiverName).GetAwaiter().GetResult(); + } + + /// + /// Enable a receiver in an action group. This changes the receiver's status + /// from Disabled to Enabled. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The name of the receiver to resubscribe. + /// + /// + /// The cancellation token. + /// + public static async Task EnableReceiverAsync(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, string receiverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.EnableReceiverWithHttpMessagesAsync(resourceGroupName, actionGroupName, receiverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActivityLogAlertsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActivityLogAlertsOperations.cs new file mode 100644 index 000000000000..a7eb0aa3dbbf --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActivityLogAlertsOperations.cs @@ -0,0 +1,1192 @@ +// 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 1.0.1.0 +// 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; + + /// + /// ActivityLogAlertsOperations operations. + /// + internal partial class ActivityLogAlertsOperations : IServiceOperations, IActivityLogAlertsOperations + { + /// + /// Initializes a new instance of the ActivityLogAlertsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ActivityLogAlertsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Create a new activity log alert or update an existing one. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// The activity log alert to create or use for the update. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (activityLogAlertName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "activityLogAlertName"); + } + if (activityLogAlert == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "activityLogAlert"); + } + if (activityLogAlert != null) + { + activityLogAlert.Validate(); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("activityLogAlertName", activityLogAlertName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("activityLogAlert", activityLogAlert); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{activityLogAlertName}", System.Uri.EscapeDataString(activityLogAlertName)); + 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("PUT"); + _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; + if(activityLogAlert != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(activityLogAlert, 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"); + } + // 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 && (int)_statusCode != 201) + { + 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); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _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; + } + + /// + /// Get an activity log alert. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// 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 resourceGroupName, string activityLogAlertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (activityLogAlertName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "activityLogAlertName"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("activityLogAlertName", activityLogAlertName); + tracingParameters.Add("apiVersion", apiVersion); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{activityLogAlertName}", System.Uri.EscapeDataString(activityLogAlertName)); + 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; + } + + /// + /// Delete an activity log alert. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// 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 + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string activityLogAlertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (activityLogAlertName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "activityLogAlertName"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("activityLogAlertName", activityLogAlertName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{activityLogAlertName}", System.Uri.EscapeDataString(activityLogAlertName)); + 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("DELETE"); + _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 && (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; + } + + /// + /// Updates an existing ActivityLogAlertResource's tags. To update other fields + /// use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (activityLogAlertName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "activityLogAlertName"); + } + if (activityLogAlertPatch == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "activityLogAlertPatch"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("activityLogAlertName", activityLogAlertName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("activityLogAlertPatch", activityLogAlertPatch); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{activityLogAlertName}", System.Uri.EscapeDataString(activityLogAlertName)); + 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("PATCH"); + _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; + if(activityLogAlertPatch != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(activityLogAlertPatch, 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"); + } + // 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; + } + + /// + /// Get a list of all activity log alerts in a subscription. + /// + /// + /// 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>> ListBySubscriptionIdWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionId", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (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; + } + + /// + /// Get a list of all activity log alerts in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + string apiVersion = "2017-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + 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/ActivityLogAlertsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActivityLogAlertsOperationsExtensions.cs new file mode 100644 index 000000000000..9e5f00a1cbea --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ActivityLogAlertsOperationsExtensions.cs @@ -0,0 +1,261 @@ +// 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 1.0.1.0 +// 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; + + /// + /// Extension methods for ActivityLogAlertsOperations. + /// + public static partial class ActivityLogAlertsOperationsExtensions + { + /// + /// Create a new activity log alert or update an existing one. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// The activity log alert to create or use for the update. + /// + public static ActivityLogAlertResource CreateOrUpdate(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert) + { + return operations.CreateOrUpdateAsync(resourceGroupName, activityLogAlertName, activityLogAlert).GetAwaiter().GetResult(); + } + + /// + /// Create a new activity log alert or update an existing one. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// The activity log alert to create or use for the update. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, activityLogAlertName, activityLogAlert, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get an activity log alert. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + public static ActivityLogAlertResource Get(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName) + { + return operations.GetAsync(resourceGroupName, activityLogAlertName).GetAwaiter().GetResult(); + } + + /// + /// Get an activity log alert. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, activityLogAlertName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an activity log alert. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + public static void Delete(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName) + { + operations.DeleteAsync(resourceGroupName, activityLogAlertName).GetAwaiter().GetResult(); + } + + /// + /// Delete an activity log alert. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, activityLogAlertName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates an existing ActivityLogAlertResource's tags. To update other fields + /// use the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// Parameters supplied to the operation. + /// + public static ActivityLogAlertResource Update(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch) + { + return operations.UpdateAsync(resourceGroupName, activityLogAlertName, activityLogAlertPatch).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing ActivityLogAlertResource's tags. To update other fields + /// use the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IActivityLogAlertsOperations operations, string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, activityLogAlertName, activityLogAlertPatch, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a list of all activity log alerts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscriptionId(this IActivityLogAlertsOperations operations) + { + return operations.ListBySubscriptionIdAsync().GetAwaiter().GetResult(); + } + + /// + /// Get a list of all activity log alerts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionIdAsync(this IActivityLogAlertsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionIdWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a list of all activity log alerts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + public static IEnumerable ListByResourceGroup(this IActivityLogAlertsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get a list of all activity log alerts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IActivityLogAlertsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperations.cs index 31f59eb4b894..9a7e0e519c33 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperations.cs @@ -643,6 +643,228 @@ internal AlertRulesOperations(MonitorManagementClient client) return _result; } + /// + /// Updates an existing AlertRuleResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (alertRulesResource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertRulesResource"); + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("alertRulesResource", alertRulesResource); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + 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("PATCH"); + _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; + if(alertRulesResource != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(alertRulesResource, 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"); + } + // 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 && (int)_statusCode != 201) + { + 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); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _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; + } + /// /// List the alert rules within a resource group. /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperationsExtensions.cs index 7b525f3239e7..5c6982b36d5f 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AlertRulesOperationsExtensions.cs @@ -147,6 +147,54 @@ public static AlertRuleResource Get(this IAlertRulesOperations operations, strin } } + /// + /// Updates an existing AlertRuleResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + public static AlertRuleResource Update(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource) + { + return operations.UpdateAsync(resourceGroupName, ruleName, alertRulesResource).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing AlertRuleResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, ruleName, alertRulesResource, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// List the alert rules within a resource group. /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperations.cs index 45b50e6f4b42..39d5c04081bb 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperations.cs @@ -813,6 +813,210 @@ internal AutoscaleSettingsOperations(MonitorManagementClient client) return _result; } + /// + /// Updates an existing AutoscaleSettingsResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The name of the resource group. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (autoscaleSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingName"); + } + if (autoscaleSettingResource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingResource"); + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("autoscaleSettingName", autoscaleSettingName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("autoscaleSettingResource", autoscaleSettingResource); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{autoscaleSettingName}", System.Uri.EscapeDataString(autoscaleSettingName)); + 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("PATCH"); + _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; + if(autoscaleSettingResource != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(autoscaleSettingResource, 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"); + } + // 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 autoscale settings for a resource group /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperationsExtensions.cs index cc9b8385113e..303ae70b4799 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/AutoscaleSettingsOperationsExtensions.cs @@ -179,6 +179,54 @@ public static AutoscaleSettingResource Get(this IAutoscaleSettingsOperations ope } } + /// + /// Updates an existing AutoscaleSettingsResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + public static AutoscaleSettingResource Update(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource) + { + return operations.UpdateAsync(resourceGroupName, autoscaleSettingName, autoscaleSettingResource).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing AutoscaleSettingsResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Lists the autoscale settings for a resource group /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs new file mode 100644 index 000000000000..14f98b1532f5 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActionGroupsOperations.cs @@ -0,0 +1,170 @@ +// 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 1.0.1.0 +// 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; + + /// + /// ActionGroupsOperations operations. + /// + public partial interface IActionGroupsOperations + { + /// + /// Create a new action group or update an existing one. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The action group to create or use for the update. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string actionGroupName, ActionGroupResource actionGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get an action group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// 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 resourceGroupName, string actionGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an action group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// 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 resourceGroupName, string actionGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a list of all action groups in a subscription. + /// + /// + /// 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>> ListBySubscriptionIdWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a list of all action groups in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Enable a receiver in an action group. This changes the receiver's + /// status from Disabled to Enabled. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the action group. + /// + /// + /// The name of the receiver to resubscribe. + /// + /// + /// 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 EnableReceiverWithHttpMessagesAsync(string resourceGroupName, string actionGroupName, string receiverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActivityLogAlertsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActivityLogAlertsOperations.cs new file mode 100644 index 000000000000..cf04d793be04 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IActivityLogAlertsOperations.cs @@ -0,0 +1,173 @@ +// 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 1.0.1.0 +// 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; + + /// + /// ActivityLogAlertsOperations operations. + /// + public partial interface IActivityLogAlertsOperations + { + /// + /// Create a new activity log alert or update an existing one. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// The activity log alert to create or use for the update. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertResource activityLogAlert, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get an activity log alert. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// 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 resourceGroupName, string activityLogAlertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an activity log alert. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// 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 resourceGroupName, string activityLogAlertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing ActivityLogAlertResource's tags. To update + /// other fields use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the activity log alert. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string activityLogAlertName, ActivityLogAlertPatchBody activityLogAlertPatch, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a list of all activity log alerts in a subscription. + /// + /// + /// 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>> ListBySubscriptionIdWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a list of all activity log alerts in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAlertRulesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAlertRulesOperations.cs index 865e9941a078..c94c0dbbcdff 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAlertRulesOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAlertRulesOperations.cs @@ -100,6 +100,35 @@ public partial interface IAlertRulesOperations /// Task> GetWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Updates an existing AlertRuleResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// List the alert rules within a resource group. /// /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAutoscaleSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAutoscaleSettingsOperations.cs index 4ae998016a58..80a890d63c60 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAutoscaleSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IAutoscaleSettingsOperations.cs @@ -122,6 +122,35 @@ public partial interface IAutoscaleSettingsOperations /// Task> GetWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Updates an existing AutoscaleSettingsResource. To update other + /// fields use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Lists the autoscale settings for a resource group /// /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ILogProfilesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ILogProfilesOperations.cs index cc7def846eae..8c54d6566789 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ILogProfilesOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ILogProfilesOperations.cs @@ -91,6 +91,32 @@ public partial interface ILogProfilesOperations /// Task> CreateOrUpdateWithHttpMessagesAsync(string logProfileName, LogProfileResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Updates an existing LogProfilesResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string logProfileName, LogProfileResourcePatch logProfilesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// List the log profiles. /// /// 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 0f8555364170..d53cc3a79f28 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IMonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IMonitorManagementClient.cs @@ -79,6 +79,11 @@ public partial interface IMonitorManagementClient : System.IDisposable /// IAlertRuleIncidentsOperations AlertRuleIncidents { get; } + /// + /// Gets the IActivityLogAlertsOperations. + /// + IActivityLogAlertsOperations ActivityLogAlerts { get; } + /// /// Gets the ILogProfilesOperations. /// @@ -89,5 +94,10 @@ public partial interface IMonitorManagementClient : System.IDisposable /// IServiceDiagnosticSettingsOperations ServiceDiagnosticSettings { get; } + /// + /// Gets the IActionGroupsOperations. + /// + IActionGroupsOperations ActionGroups { get; } + } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs index 448d06067ff1..ca638736f7d6 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/IServiceDiagnosticSettingsOperations.cs @@ -100,6 +100,6 @@ public partial interface IServiceDiagnosticSettingsOperations /// /// Thrown when a required parameter is null /// - Task> UpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResource serviceDiagnosticSettingsResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> UpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperations.cs index 07af14beefdd..e6983b7d69b3 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperations.cs @@ -598,6 +598,201 @@ internal LogProfilesOperations(MonitorManagementClient client) return _result; } + /// + /// Updates an existing LogProfilesResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string logProfileName, LogProfileResourcePatch logProfilesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (logProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfileName"); + } + if (logProfilesResource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfilesResource"); + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("logProfileName", logProfileName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("logProfilesResource", logProfilesResource); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{logProfileName}", System.Uri.EscapeDataString(logProfileName)); + 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("PATCH"); + _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; + if(logProfilesResource != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(logProfilesResource, 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"); + } + // 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; + } + /// /// List the log profiles. /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperationsExtensions.cs index 6801faa0a15f..91d6d4cf3f51 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/LogProfilesOperationsExtensions.cs @@ -129,6 +129,48 @@ public static LogProfileResource CreateOrUpdate(this ILogProfilesOperations oper } } + /// + /// Updates an existing LogProfilesResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + public static LogProfileResource Update(this ILogProfilesOperations operations, string logProfileName, LogProfileResourcePatch logProfilesResource) + { + return operations.UpdateAsync(logProfileName, logProfilesResource).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing LogProfilesResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ILogProfilesOperations operations, string logProfileName, LogProfileResourcePatch logProfilesResource, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(logProfileName, logProfilesResource, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// List the log profiles. /// 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 new file mode 100644 index 000000000000..5a7a1825006c --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActionGroupResource.cs @@ -0,0 +1,150 @@ +// 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 1.0.1.0 +// 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; + + /// + /// An action group resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ActionGroupResource : Resource + { + /// + /// Initializes a new instance of the ActionGroupResource class. + /// + public ActionGroupResource() { } + + /// + /// Initializes a new instance of the ActionGroupResource class. + /// + /// Resource location + /// The short name of the action group. + /// 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. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// The list of email receivers that are + /// part of this action group. + /// The list of SMS receivers that are part + /// of this action group. + /// The list of webhook receivers that + /// are part of this action group. + public ActionGroupResource(string location, string groupShortName, bool enabled, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList emailReceivers = default(IList), IList smsReceivers = default(IList), IList webhookReceivers = default(IList)) + : base(location, id, name, type, tags) + { + GroupShortName = groupShortName; + Enabled = enabled; + EmailReceivers = emailReceivers; + SmsReceivers = smsReceivers; + WebhookReceivers = webhookReceivers; + } + + /// + /// Gets or sets the short name of the action group. This will be used + /// in SMS messages. + /// + [JsonProperty(PropertyName = "properties.groupShortName")] + public string GroupShortName { get; set; } + + /// + /// Gets or sets indicates whether this action group is enabled. If an + /// action group is not enabled, then none of its receviers will + /// receive communications. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the list of email receivers that are part of this + /// action group. + /// + [JsonProperty(PropertyName = "properties.emailReceivers")] + public IList EmailReceivers { get; set; } + + /// + /// Gets or sets the list of SMS receivers that are part of this action + /// group. + /// + [JsonProperty(PropertyName = "properties.smsReceivers")] + public IList SmsReceivers { get; set; } + + /// + /// Gets or sets the list of webhook receivers that are part of this + /// action group. + /// + [JsonProperty(PropertyName = "properties.webhookReceivers")] + public IList WebhookReceivers { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (GroupShortName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "GroupShortName"); + } + if (GroupShortName != null) + { + if (GroupShortName.Length > 15) + { + throw new ValidationException(ValidationRules.MaxLength, "GroupShortName", 15); + } + } + if (EmailReceivers != null) + { + foreach (var element in EmailReceivers) + { + if (element != null) + { + element.Validate(); + } + } + } + if (SmsReceivers != null) + { + foreach (var element1 in SmsReceivers) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (WebhookReceivers != null) + { + foreach (var element2 in WebhookReceivers) + { + if (element2 != null) + { + element2.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertActionGroup.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertActionGroup.cs new file mode 100644 index 000000000000..fba22c0d98b0 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertActionGroup.cs @@ -0,0 +1,75 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A pointer to an Azure Action Group. + /// + public partial class ActivityLogAlertActionGroup + { + /// + /// Initializes a new instance of the ActivityLogAlertActionGroup + /// class. + /// + public ActivityLogAlertActionGroup() { } + + /// + /// Initializes a new instance of the ActivityLogAlertActionGroup + /// class. + /// + /// The resourceId of the action group. + /// This cannot be null or empty. + /// the dictionary of custom properties + /// to include with the post operation. These data are appended to the + /// webhook payload. + public ActivityLogAlertActionGroup(string actionGroupId, IDictionary webhookProperties = default(IDictionary)) + { + ActionGroupId = actionGroupId; + WebhookProperties = webhookProperties; + } + + /// + /// Gets or sets the resourceId of the action group. This cannot be + /// null or empty. + /// + [JsonProperty(PropertyName = "actionGroupId")] + public string ActionGroupId { get; set; } + + /// + /// Gets or sets the dictionary of custom properties to include with + /// the post operation. These data are appended to the webhook payload. + /// + [JsonProperty(PropertyName = "webhookProperties")] + public IDictionary WebhookProperties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ActionGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ActionGroupId"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertActionList.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertActionList.cs new file mode 100644 index 000000000000..ba74f11e3683 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertActionList.cs @@ -0,0 +1,46 @@ +// 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 1.0.1.0 +// 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; + + /// + /// A list of activity log alert actions. + /// + public partial class ActivityLogAlertActionList + { + /// + /// Initializes a new instance of the ActivityLogAlertActionList class. + /// + public ActivityLogAlertActionList() { } + + /// + /// Initializes a new instance of the ActivityLogAlertActionList class. + /// + /// The list of activity log alerts. + public ActivityLogAlertActionList(IList actionGroups = default(IList)) + { + ActionGroups = actionGroups; + } + + /// + /// Gets or sets the list of activity log alerts. + /// + [JsonProperty(PropertyName = "actionGroups")] + public IList ActionGroups { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertAllOfCondition.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertAllOfCondition.cs new file mode 100644 index 000000000000..3519e9decedc --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertAllOfCondition.cs @@ -0,0 +1,74 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Activity Log alert condition that is met when all its member + /// conditions are met. + /// + public partial class ActivityLogAlertAllOfCondition + { + /// + /// Initializes a new instance of the ActivityLogAlertAllOfCondition + /// class. + /// + public ActivityLogAlertAllOfCondition() { } + + /// + /// Initializes a new instance of the ActivityLogAlertAllOfCondition + /// class. + /// + /// The list of activity log alert + /// conditions. + public ActivityLogAlertAllOfCondition(IList allOf) + { + AllOf = allOf; + } + + /// + /// Gets or sets the list of activity log alert conditions. + /// + [JsonProperty(PropertyName = "allOf")] + public IList AllOf { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AllOf == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AllOf"); + } + if (AllOf != null) + { + foreach (var element in AllOf) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertLeafCondition.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertLeafCondition.cs new file mode 100644 index 000000000000..28eef667b4f9 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertLeafCondition.cs @@ -0,0 +1,83 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Linq; + + /// + /// An Activity Log alert condition that is met by comparing an activity + /// log field and value. + /// + public partial class ActivityLogAlertLeafCondition + { + /// + /// Initializes a new instance of the ActivityLogAlertLeafCondition + /// class. + /// + public ActivityLogAlertLeafCondition() { } + + /// + /// Initializes a new instance of the ActivityLogAlertLeafCondition + /// class. + /// + /// The name of the field that this condition will + /// examine. The possible values for this field are (case-insensitive): + /// 'resourceId', 'category', 'caller', 'level', 'operationName', + /// 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + /// 'resourceType', or anything beginning with 'properties.'. + /// The field value will be compared to this value + /// (case-insensitive) to determine if the condition is met. + public ActivityLogAlertLeafCondition(string field, string equals) + { + Field = field; + Equals = equals; + } + + /// + /// Gets or sets the name of the field that this condition will + /// examine. The possible values for this field are (case-insensitive): + /// 'resourceId', 'category', 'caller', 'level', 'operationName', + /// 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + /// 'resourceType', or anything beginning with 'properties.'. + /// + [JsonProperty(PropertyName = "field")] + public string Field { get; set; } + + /// + /// Gets or sets the field value will be compared to this value + /// (case-insensitive) to determine if the condition is met. + /// + [JsonProperty(PropertyName = "equals")] + public string Equals { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Field == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Field"); + } + if (Equals == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Equals"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertPatchBody.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertPatchBody.cs new file mode 100644 index 000000000000..d196db72c807 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertPatchBody.cs @@ -0,0 +1,61 @@ +// 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 1.0.1.0 +// 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; + + /// + /// An activity log alert object for the body of patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class ActivityLogAlertPatchBody + { + /// + /// Initializes a new instance of the ActivityLogAlertPatchBody class. + /// + public ActivityLogAlertPatchBody() { } + + /// + /// Initializes a new instance of the ActivityLogAlertPatchBody class. + /// + /// Resource tags + /// Indicates whether this activity log alert is + /// enabled. If an activity log alert is not enabled, then none of its + /// actions will be activated. + public ActivityLogAlertPatchBody(IDictionary tags = default(IDictionary), bool? enabled = default(bool?)) + { + Tags = tags; + Enabled = enabled; + } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets indicates whether this activity log alert is enabled. + /// If an activity log alert is not enabled, then none of its actions + /// will be activated. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool? Enabled { get; set; } + + } +} 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 new file mode 100644 index 000000000000..acd7a09f6cb9 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ActivityLogAlertResource.cs @@ -0,0 +1,127 @@ +// 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 1.0.1.0 +// 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; + + /// + /// An activity log alert resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ActivityLogAlertResource : Resource + { + /// + /// Initializes a new instance of the ActivityLogAlertResource class. + /// + public ActivityLogAlertResource() { } + + /// + /// Initializes a new instance of the ActivityLogAlertResource class. + /// + /// Resource location + /// A list of resourceIds that will be used as + /// 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 + /// activate. + /// The actions that will activate when the + /// condition is met. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// Indicates whether this activity log alert is + /// enabled. If an activity log alert is not enabled, then none of its + /// actions will be activated. + /// A description of this activity log + /// alert. + public ActivityLogAlertResource(string location, IList scopes, ActivityLogAlertAllOfCondition condition, ActivityLogAlertActionList actions, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), bool? enabled = default(bool?), string description = default(string)) + : base(location, id, name, type, tags) + { + Scopes = scopes; + Enabled = enabled; + Condition = condition; + Actions = actions; + Description = description; + } + + /// + /// Gets or sets a list of resourceIds that will be used as 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. + /// + [JsonProperty(PropertyName = "properties.scopes")] + public IList Scopes { get; set; } + + /// + /// Gets or sets indicates whether this activity log alert is enabled. + /// If an activity log alert is not enabled, then none of its actions + /// will be activated. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool? Enabled { get; set; } + + /// + /// Gets or sets the conditon that will cause this alert to activate. + /// + [JsonProperty(PropertyName = "properties.condition")] + public ActivityLogAlertAllOfCondition Condition { get; set; } + + /// + /// Gets or sets the actions that will activate when the condition is + /// met. + /// + [JsonProperty(PropertyName = "properties.actions")] + public ActivityLogAlertActionList Actions { get; set; } + + /// + /// Gets or sets a description of this activity log alert. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Scopes == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Scopes"); + } + if (Condition == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Condition"); + } + if (Actions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Actions"); + } + if (Condition != null) + { + Condition.Validate(); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/AlertRuleResourcePatch.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/AlertRuleResourcePatch.cs new file mode 100644 index 000000000000..4778d4e7bf4c --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/AlertRuleResourcePatch.cs @@ -0,0 +1,124 @@ +// 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 1.0.1.0 +// 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; + + /// + /// The alert rule object for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class AlertRuleResourcePatch + { + /// + /// Initializes a new instance of the AlertRuleResourcePatch class. + /// + public AlertRuleResourcePatch() { } + + /// + /// Initializes a new instance of the AlertRuleResourcePatch class. + /// + /// the name of the alert rule. + /// the flag that indicates whether the alert + /// rule is enabled. + /// the condition that results in the alert + /// rule being activated. + /// Resource tags + /// the description of the alert rule that + /// will be included in the alert email. + /// the array of actions that are performed when + /// the alert rule becomes active, and when an alert condition is + /// resolved. + /// Last time the rule was updated in + /// ISO8601 format. + public AlertRuleResourcePatch(string name, bool isEnabled, RuleCondition condition, IDictionary tags = default(IDictionary), string description = default(string), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?)) + { + Tags = tags; + Name = name; + Description = description; + IsEnabled = isEnabled; + Condition = condition; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name of the alert rule. + /// + [JsonProperty(PropertyName = "properties.name")] + public string Name { get; set; } + + /// + /// Gets or sets the description of the alert rule that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert rule is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.isEnabled")] + public bool IsEnabled { get; set; } + + /// + /// Gets or sets the condition that results in the alert rule being + /// activated. + /// + [JsonProperty(PropertyName = "properties.condition")] + public RuleCondition Condition { get; set; } + + /// + /// Gets or sets the array of actions that are performed when the alert + /// rule becomes active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets last time the rule was updated in ISO8601 format. + /// + [JsonProperty(PropertyName = "properties.lastUpdatedTime")] + public System.DateTime? LastUpdatedTime { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Condition == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Condition"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/AutoscaleSettingResourcePatch.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/AutoscaleSettingResourcePatch.cs new file mode 100644 index 000000000000..0a5b62cfb94f --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/AutoscaleSettingResourcePatch.cs @@ -0,0 +1,128 @@ +// 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 1.0.1.0 +// 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; + + /// + /// The autoscale setting object for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class AutoscaleSettingResourcePatch + { + /// + /// Initializes a new instance of the AutoscaleSettingResourcePatch + /// class. + /// + public AutoscaleSettingResourcePatch() { } + + /// + /// Initializes a new instance of the AutoscaleSettingResourcePatch + /// class. + /// + /// the collection of automatic scaling profiles + /// that specify different scaling parameters for different time + /// periods. A maximum of 20 profiles can be specified. + /// Resource tags + /// the collection of + /// notifications. + /// the enabled flag. Specifies whether automatic + /// scaling is enabled for the resource. The default value is + /// 'true'. + /// the name of the autoscale setting. + /// the resource identifier of the + /// resource that the autoscale setting should be added to. + public AutoscaleSettingResourcePatch(IList profiles, IDictionary tags = default(IDictionary), IList notifications = default(IList), bool? enabled = default(bool?), string name = default(string), string targetResourceUri = default(string)) + { + Tags = tags; + Profiles = profiles; + Notifications = notifications; + Enabled = enabled; + Name = name; + TargetResourceUri = targetResourceUri; + } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the collection of automatic scaling profiles that + /// specify different scaling parameters for different time periods. A + /// maximum of 20 profiles can be specified. + /// + [JsonProperty(PropertyName = "properties.profiles")] + public IList Profiles { get; set; } + + /// + /// Gets or sets the collection of notifications. + /// + [JsonProperty(PropertyName = "properties.notifications")] + public IList Notifications { get; set; } + + /// + /// Gets or sets the enabled flag. Specifies whether automatic scaling + /// is enabled for the resource. The default value is 'true'. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool? Enabled { get; set; } + + /// + /// Gets or sets the name of the autoscale setting. + /// + [JsonProperty(PropertyName = "properties.name")] + public string Name { get; set; } + + /// + /// Gets or sets the resource identifier of the resource that the + /// autoscale setting should be added to. + /// + [JsonProperty(PropertyName = "properties.targetResourceUri")] + public string TargetResourceUri { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Profiles == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Profiles"); + } + if (Profiles != null) + { + if (Profiles.Count > 20) + { + throw new ValidationException(ValidationRules.MaxItems, "Profiles", 20); + } + foreach (var element in Profiles) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} 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 new file mode 100644 index 000000000000..7ec40c4f0b95 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EmailReceiver.cs @@ -0,0 +1,82 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Linq; + + /// + /// An email receiver. + /// + public partial class EmailReceiver + { + /// + /// Initializes a new instance of the EmailReceiver class. + /// + public EmailReceiver() { } + + /// + /// Initializes a new instance of the EmailReceiver class. + /// + /// The name of the email receiver. Names must be + /// unique across all receivers within an action group. + /// The email address of this + /// receiver. + /// Possible values include: 'NotSpecified', + /// 'Enabled', 'Disabled' + public EmailReceiver(string name, string emailAddress, ReceiverStatus? status = default(ReceiverStatus?)) + { + Name = name; + EmailAddress = emailAddress; + Status = status; + } + + /// + /// Gets or sets the name of the email receiver. Names must be unique + /// across all receivers within an action group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the email address of this receiver. + /// + [JsonProperty(PropertyName = "emailAddress")] + public string EmailAddress { get; set; } + + /// + /// Gets possible values include: 'NotSpecified', 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "status")] + public ReceiverStatus? Status { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (EmailAddress == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EmailAddress"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EnableRequest.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EnableRequest.cs new file mode 100644 index 000000000000..e58674cdd6d9 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/EnableRequest.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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Linq; + + /// + /// Describes a receiver that should be resubscribed. + /// + public partial class EnableRequest + { + /// + /// Initializes a new instance of the EnableRequest class. + /// + public EnableRequest() { } + + /// + /// Initializes a new instance of the EnableRequest class. + /// + /// The name of the receiver to + /// resubscribe. + public EnableRequest(string receiverName) + { + ReceiverName = receiverName; + } + + /// + /// Gets or sets the name of the receiver to resubscribe. + /// + [JsonProperty(PropertyName = "receiverName")] + public string ReceiverName { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ReceiverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ReceiverName"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LocationThresholdRuleCondition.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LocationThresholdRuleCondition.cs index f215e8d9bf99..e969af310b32 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LocationThresholdRuleCondition.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LocationThresholdRuleCondition.cs @@ -12,6 +12,7 @@ namespace Microsoft.Azure.Management.Monitor.Management.Models using Microsoft.Azure.Management; using Microsoft.Azure.Management.Monitor; using Microsoft.Azure.Management.Monitor.Management; + using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; @@ -65,12 +66,15 @@ public LocationThresholdRuleCondition() { } /// /// Validate the object. /// - /// + /// /// Thrown if validation fails /// public virtual void Validate() { - //Nothing to validate + if (FailedLocationCount < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "FailedLocationCount", 0); + } } } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LogProfileResourcePatch.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LogProfileResourcePatch.cs new file mode 100644 index 000000000000..0db66d3c5679 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/LogProfileResourcePatch.cs @@ -0,0 +1,132 @@ +// 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 1.0.1.0 +// 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; + + /// + /// The log profile resource for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class LogProfileResourcePatch + { + /// + /// Initializes a new instance of the LogProfileResourcePatch class. + /// + public LogProfileResourcePatch() { } + + /// + /// Initializes a new instance of the LogProfileResourcePatch class. + /// + /// List of regions for which Activity Log + /// events should be stored or streamed. It is a comma separated list + /// of valid ARM locations including the 'global' location. + /// the categories of the logs. These + /// categories are created as is convenient to the user. Some values + /// are: 'Write', 'Delete', and/or 'Action.' + /// the retention policy for the events + /// in the log. + /// Resource tags + /// the resource id of the storage + /// account to which you would like to send the Activity Log. + /// The service bus rule ID of the + /// service bus namespace in which you would like to have Event Hubs + /// created for streaming the Activity Log. The rule ID is of the + /// format: '{service bus resource ID}/authorizationrules/{key + /// name}'. + public LogProfileResourcePatch(IList locations, IList categories, RetentionPolicy retentionPolicy, IDictionary tags = default(IDictionary), string storageAccountId = default(string), string serviceBusRuleId = default(string)) + { + Tags = tags; + StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; + Locations = locations; + Categories = categories; + RetentionPolicy = retentionPolicy; + } + + /// + /// 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 the Activity Log. + /// + [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 + /// the Activity Log. 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 list of regions for which Activity Log events should + /// be stored or streamed. It is a comma separated list of valid ARM + /// locations including the 'global' location. + /// + [JsonProperty(PropertyName = "properties.locations")] + public IList Locations { get; set; } + + /// + /// Gets or sets the categories of the logs. These categories are + /// created as is convenient to the user. Some values are: 'Write', + /// 'Delete', and/or 'Action.' + /// + [JsonProperty(PropertyName = "properties.categories")] + public IList Categories { get; set; } + + /// + /// Gets or sets the retention policy for the events in the log. + /// + [JsonProperty(PropertyName = "properties.retentionPolicy")] + public RetentionPolicy RetentionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Locations == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Locations"); + } + if (Categories == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Categories"); + } + if (RetentionPolicy == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RetentionPolicy"); + } + if (RetentionPolicy != null) + { + RetentionPolicy.Validate(); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ReceiverStatus.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ReceiverStatus.cs new file mode 100644 index 000000000000..ba05b4fa8b9c --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ReceiverStatus.cs @@ -0,0 +1,33 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ReceiverStatus. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ReceiverStatus + { + [EnumMember(Value = "NotSpecified")] + NotSpecified, + [EnumMember(Value = "Enabled")] + Enabled, + [EnumMember(Value = "Disabled")] + Disabled + } +} 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 new file mode 100644 index 000000000000..59affa8e5b1d --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/ServiceDiagnosticSettingsResourcePatch.cs @@ -0,0 +1,115 @@ +// 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 1.0.1.0 +// 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() { } + + /// + /// 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; + } + + /// + /// 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 new file mode 100644 index 000000000000..980e591d8dc3 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/SmsReceiver.cs @@ -0,0 +1,95 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Linq; + + /// + /// An SMS receiver. + /// + public partial class SmsReceiver + { + /// + /// Initializes a new instance of the SmsReceiver class. + /// + public SmsReceiver() { } + + /// + /// Initializes a new instance of the SmsReceiver class. + /// + /// The name of the SMS receiver. Names must be + /// unique across all receivers within an action group. + /// The country code of the SMS + /// receiver. + /// The phone number of the SMS + /// receiver. + /// Possible values include: 'NotSpecified', + /// 'Enabled', 'Disabled' + public SmsReceiver(string name, string countryCode, string phoneNumber, ReceiverStatus? status = default(ReceiverStatus?)) + { + Name = name; + CountryCode = countryCode; + PhoneNumber = phoneNumber; + Status = status; + } + + /// + /// Gets or sets the name of the SMS receiver. Names must be unique + /// across all receivers within an action group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the country code of the SMS receiver. + /// + [JsonProperty(PropertyName = "countryCode")] + public string CountryCode { get; set; } + + /// + /// Gets or sets the phone number of the SMS receiver. + /// + [JsonProperty(PropertyName = "phoneNumber")] + public string PhoneNumber { get; set; } + + /// + /// Gets possible values include: 'NotSpecified', 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "status")] + public ReceiverStatus? Status { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (CountryCode == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CountryCode"); + } + if (PhoneNumber == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PhoneNumber"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/WebhookReceiver.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/WebhookReceiver.cs new file mode 100644 index 000000000000..d1c82b6c6be3 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/Models/WebhookReceiver.cs @@ -0,0 +1,73 @@ +// 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 1.0.1.0 +// 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 Newtonsoft.Json; + using System.Linq; + + /// + /// A webhook receiver. + /// + public partial class WebhookReceiver + { + /// + /// Initializes a new instance of the WebhookReceiver class. + /// + public WebhookReceiver() { } + + /// + /// Initializes a new instance of the WebhookReceiver class. + /// + /// The name of the webhook receiver. Names must be + /// unique across all receivers within an action group. + /// The URI where webhooks should be + /// sent. + public WebhookReceiver(string name, string serviceUri) + { + Name = name; + ServiceUri = serviceUri; + } + + /// + /// Gets or sets the name of the webhook receiver. Names must be unique + /// across all receivers within an action group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the URI where webhooks should be sent. + /// + [JsonProperty(PropertyName = "serviceUri")] + public string ServiceUri { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (ServiceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ServiceUri"); + } + } + } +} 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 dad9917e3114..71d18258874e 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/MonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/MonitorManagementClient.cs @@ -84,6 +84,11 @@ public partial class MonitorManagementClient : ServiceClient public virtual IAlertRuleIncidentsOperations AlertRuleIncidents { get; private set; } + /// + /// Gets the IActivityLogAlertsOperations. + /// + public virtual IActivityLogAlertsOperations ActivityLogAlerts { get; private set; } + /// /// Gets the ILogProfilesOperations. /// @@ -94,6 +99,11 @@ public partial class MonitorManagementClient : ServiceClient public virtual IServiceDiagnosticSettingsOperations ServiceDiagnosticSettings { get; private set; } + /// + /// Gets the IActionGroupsOperations. + /// + public virtual IActionGroupsOperations ActionGroups { get; private set; } + /// /// Initializes a new instance of the MonitorManagementClient class. /// @@ -298,8 +308,10 @@ private void Initialize() AutoscaleSettings = new AutoscaleSettingsOperations(this); AlertRules = new AlertRulesOperations(this); AlertRuleIncidents = new AlertRuleIncidentsOperations(this); + ActivityLogAlerts = new ActivityLogAlertsOperations(this); LogProfiles = new LogProfilesOperations(this); ServiceDiagnosticSettings = new ServiceDiagnosticSettingsOperations(this); + ActionGroups = new ActionGroupsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs index b1c72ff89052..e83566d192a5 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperations.cs @@ -458,7 +458,7 @@ internal ServiceDiagnosticSettingsOperations(MonitorManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> UpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResource serviceDiagnosticSettingsResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> UpdateWithHttpMessagesAsync(string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceUri == null) { diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs index fd69889bc068..272e8d5e8ba8 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Management/Monitor/ServiceDiagnosticSettingsOperationsExtensions.cs @@ -114,7 +114,7 @@ public static ServiceDiagnosticSettingsResource CreateOrUpdate(this IServiceDiag /// /// Parameters supplied to the operation. /// - public static ServiceDiagnosticSettingsResource Update(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResource serviceDiagnosticSettingsResource) + public static ServiceDiagnosticSettingsResource Update(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResourcePatch serviceDiagnosticSettingsResource) { return operations.UpdateAsync(resourceUri, serviceDiagnosticSettingsResource).GetAwaiter().GetResult(); } @@ -136,7 +136,7 @@ public static ServiceDiagnosticSettingsResource Update(this IServiceDiagnosticSe /// /// The cancellation token. /// - public static async Task UpdateAsync(this IServiceDiagnosticSettingsOperations operations, string resourceUri, ServiceDiagnosticSettingsResource serviceDiagnosticSettingsResource, CancellationToken cancellationToken = default(CancellationToken)) + 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)) { diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperations.cs index ee13b672beaa..a2fa562523fd 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperations.cs @@ -52,37 +52,19 @@ internal ActivityLogsOperations(MonitorClient client) public MonitorClient Client { get; private set; } /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List events - /// for resource: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br><br>**NOTE**: No - /// other syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is a comma - /// separated list of property names to be returned. Possible values are: - /// authorization, channels, claims, correlationId, description, eventDataId, - /// eventName, eventTimestamp, httpRequest, level, operationId, operationName, - /// properties, resourceGroupName, resourceProviderName, resourceId, status, - /// submissionTimestamp, subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* /// /// /// Headers that will be added to request. @@ -267,26 +249,7 @@ internal ActivityLogsOperations(MonitorClient client) } /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List events - /// for resource: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br><br>**NOTE**: No - /// other syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperationsExtensions.cs index 3ee582d91815..14f7fe6770fe 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ActivityLogsOperationsExtensions.cs @@ -23,26 +23,7 @@ namespace Microsoft.Azure.Management.Monitor public static partial class ActivityLogsOperationsExtensions { /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List events - /// for resource: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br><br>**NOTE**: No - /// other syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// The operations group for this extension method. @@ -51,12 +32,13 @@ public static partial class ActivityLogsOperationsExtensions /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is a comma - /// separated list of property names to be returned. Possible values are: - /// authorization, channels, claims, correlationId, description, eventDataId, - /// eventName, eventTimestamp, httpRequest, level, operationId, operationName, - /// properties, resourceGroupName, resourceProviderName, resourceId, status, - /// submissionTimestamp, subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* /// public static IPage List(this IActivityLogsOperations operations, ODataQuery odataQuery = default(ODataQuery), string select = default(string)) { @@ -64,26 +46,7 @@ public static partial class ActivityLogsOperationsExtensions } /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List events - /// for resource: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br><br>**NOTE**: No - /// other syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// The operations group for this extension method. @@ -92,12 +55,13 @@ public static partial class ActivityLogsOperationsExtensions /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is a comma - /// separated list of property names to be returned. Possible values are: - /// authorization, channels, claims, correlationId, description, eventDataId, - /// eventName, eventTimestamp, httpRequest, level, operationId, operationName, - /// properties, resourceGroupName, resourceProviderName, resourceId, status, - /// submissionTimestamp, subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* /// /// /// The cancellation token. @@ -111,26 +75,7 @@ public static partial class ActivityLogsOperationsExtensions } /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List events - /// for resource: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br><br>**NOTE**: No - /// other syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// The operations group for this extension method. @@ -144,26 +89,7 @@ public static IPage ListNext(this IActivityLogsOperations operations, } /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List events - /// for resource: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br><br>**NOTE**: No - /// other syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// The operations group for this extension method. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IActivityLogsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IActivityLogsOperations.cs index 13a9fd76d3fa..9324e5e433c0 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IActivityLogsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IActivityLogsOperations.cs @@ -25,41 +25,20 @@ namespace Microsoft.Azure.Management.Monitor public partial interface IActivityLogsOperations { /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List - /// events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq - /// 'Admin, Operation' and resourceUri eq - /// '<ResourceURI>'.<br>- List events for a subscription: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List - /// events for a correlation Id: - /// api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, - /// Operation' and correlationId eq - /// '<CorrelationID>'.<br><br>**NOTE**: No other - /// syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is - /// a comma separated list of property names to be returned. Possible - /// values are: authorization, channels, claims, correlationId, - /// description, eventDataId, eventName, eventTimestamp, httpRequest, - /// level, operationId, operationName, properties, resourceGroupName, - /// resourceProviderName, resourceId, status, submissionTimestamp, - /// subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to + /// be returned. Possible values are: *authorization*, *claims*, + /// *correlationId*, *description*, *eventDataId*, *eventName*, + /// *eventTimestamp*, *httpRequest*, *level*, *operationId*, + /// *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, + /// *submissionTimestamp*, *subStatus*, *subscriptionId* /// /// /// The headers that will be added to request. @@ -78,29 +57,7 @@ public partial interface IActivityLogsOperations /// Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), string select = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Provides the list of records from the activity logs.<br>The - /// **$filter** is very restricted and allows only the following - /// patterns.<br>- List events for a resource group: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceGroupName eq '<ResourceGroupName>'.<br>- List - /// events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq - /// 'Admin, Operation' and resourceUri eq - /// '<ResourceURI>'.<br>- List events for a subscription: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>-List events for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List - /// events for a correlation Id: - /// api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, - /// Operation' and correlationId eq - /// '<CorrelationID>'.<br><br>**NOTE**: No other - /// syntax is allowed. + /// Provides the list of records from the activity logs. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricDefinitionsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricDefinitionsOperations.cs index 34ad354c9200..54a6a80f9a49 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricDefinitionsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricDefinitionsOperations.cs @@ -25,14 +25,7 @@ namespace Microsoft.Azure.Management.Monitor public partial interface IMetricDefinitionsOperations { /// - /// Lists the metric definitions for the resource.<br>The - /// **$filter** parameter is optional, and can be used to only retrieve - /// certain metric definitions.<br>For example, get just the - /// definition for the CPU percentage counter: $filter=name.value eq - /// '\Processor(_Total)\% Processor Time'.<br>This **$filter** is - /// very restricted and allows only clauses of the form **'name eq - /// <value>'** separated by **or** logical - /// operators.<br>**NOTE**: No other syntax is allowed. + /// Lists the metric definitions for the resource. /// /// /// The identifier of the resource. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricsOperations.cs index edcb0d334673..aba8253e7b75 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/IMetricsOperations.cs @@ -25,28 +25,7 @@ namespace Microsoft.Azure.Management.Monitor public partial interface IMetricsOperations { /// - /// Lists the metric values for a resource.<br>The **$filter** is - /// used to reduce the set of metric data returned. Some common - /// properties for this expression will be: name.value, - /// aggregationType, startTime, endTime, timeGrain.<br>The filter - /// expression uses these properties with comparison operators (eg. eq, - /// gt, lt) and multiple expressions can be combined with parentheses - /// and 'and/or' logical operators.<br>Some example filter - /// expressions are:<br>- $filter=(name.value eq 'RunsSucceeded') - /// and aggregationType eq 'Total' and startTime eq 2016-02-20 and - /// endTime eq 2016-02-21 and timeGrain eq duration'PT1M',<br>- - /// $filter=(name.value eq 'RunsSucceeded') and (aggregationType eq - /// 'Total' or aggregationType eq 'Average') and startTime eq - /// 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - /// duration'PT1H',<br>- $filter=(name.value eq - /// 'ActionsCompleted' or name.value eq 'RunsSucceeded') and - /// (aggregationType eq 'Total' or aggregationType eq 'Average') and - /// startTime eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - /// duration'PT1M'.<br><br> >**NOTE**: When a metrics - /// query comes in with multiple metrics, but with no aggregation types - /// defined, the service will pick the Primary aggregation type of the - /// first metrics to be used as the default aggregation type for all - /// the metrics. + /// Lists the metric values for a resource. /// /// /// The identifier of the resource. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ITenantActivityLogsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ITenantActivityLogsOperations.cs index 59786e256ae2..a16525eb0aad 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ITenantActivityLogsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/ITenantActivityLogsOperations.cs @@ -31,40 +31,20 @@ public partial interface ITenantActivityLogsOperations /// etc.).<br>One thing to point out here is that this API does /// *not* retrieve the logs at the individual subscription of the /// tenant but only surfaces the logs that were generated at the tenant - /// level.<br>The **$filter** is very restricted and allows only - /// the following patterns.<br>- List events for a resource - /// group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq - /// '<ResourceGroupName>'.<br>- List events for resource: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceUri eq '<ResourceURI>'.<br>- List events for a - /// subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List - /// events for a correlation Id: - /// api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, - /// Operation' and correlationId eq - /// '<CorrelationID>'.<br>**NOTE**: No other syntax is - /// allowed. + /// level. /// /// /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is - /// a comma separated list of property names to be returned. Possible - /// values are: authorization, channels, claims, correlationId, - /// description, eventDataId, eventName, eventTimestamp, httpRequest, - /// level, operationId, operationName, properties, resourceGroupName, - /// resourceProviderName, resourceId, status, submissionTimestamp, - /// subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to + /// be returned. Possible values are: *authorization*, *claims*, + /// *correlationId*, *description*, *eventDataId*, *eventName*, + /// *eventTimestamp*, *httpRequest*, *level*, *operationId*, + /// *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, + /// *submissionTimestamp*, *subStatus*, *subscriptionId* /// /// /// The headers that will be added to request. @@ -89,28 +69,7 @@ public partial interface ITenantActivityLogsOperations /// etc.).<br>One thing to point out here is that this API does /// *not* retrieve the logs at the individual subscription of the /// tenant but only surfaces the logs that were generated at the tenant - /// level.<br>The **$filter** is very restricted and allows only - /// the following patterns.<br>- List events for a resource - /// group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq - /// '<ResourceGroupName>'.<br>- List events for resource: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceUri eq '<ResourceURI>'.<br>- List events for a - /// subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp - /// le '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List - /// events for a correlation Id: - /// api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, - /// Operation' and correlationId eq - /// '<CorrelationID>'.<br>**NOTE**: No other syntax is - /// allowed. + /// level. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperations.cs index b0207515a84e..49c2de36ced1 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperations.cs @@ -52,13 +52,7 @@ internal MetricDefinitionsOperations(MonitorClient client) public MonitorClient Client { get; private set; } /// - /// Lists the metric definitions for the resource.<br>The **$filter** - /// parameter is optional, and can be used to only retrieve certain metric - /// definitions.<br>For example, get just the definition for the CPU - /// percentage counter: $filter=name.value eq '\Processor(_Total)\% Processor - /// Time'.<br>This **$filter** is very restricted and allows only clauses - /// of the form **'name eq <value>'** separated by **or** logical - /// operators.<br>**NOTE**: No other syntax is allowed. + /// Lists the metric definitions for the resource. /// /// /// The identifier of the resource. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperationsExtensions.cs index 4321f0a78cc0..a5db3980d77c 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricDefinitionsOperationsExtensions.cs @@ -25,13 +25,7 @@ namespace Microsoft.Azure.Management.Monitor public static partial class MetricDefinitionsOperationsExtensions { /// - /// Lists the metric definitions for the resource.<br>The **$filter** - /// parameter is optional, and can be used to only retrieve certain metric - /// definitions.<br>For example, get just the definition for the CPU - /// percentage counter: $filter=name.value eq '\Processor(_Total)\% Processor - /// Time'.<br>This **$filter** is very restricted and allows only clauses - /// of the form **'name eq <value>'** separated by **or** logical - /// operators.<br>**NOTE**: No other syntax is allowed. + /// Lists the metric definitions for the resource. /// /// /// The operations group for this extension method. @@ -48,13 +42,7 @@ public static partial class MetricDefinitionsOperationsExtensions } /// - /// Lists the metric definitions for the resource.<br>The **$filter** - /// parameter is optional, and can be used to only retrieve certain metric - /// definitions.<br>For example, get just the definition for the CPU - /// percentage counter: $filter=name.value eq '\Processor(_Total)\% Processor - /// Time'.<br>This **$filter** is very restricted and allows only clauses - /// of the form **'name eq <value>'** separated by **or** logical - /// operators.<br>**NOTE**: No other syntax is allowed. + /// Lists the metric definitions for the resource. /// /// /// The operations group for this extension method. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperations.cs index f72b7d4ba40d..0265ae9cdc3f 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperations.cs @@ -52,25 +52,7 @@ internal MetricsOperations(MonitorClient client) public MonitorClient Client { get; private set; } /// - /// Lists the metric values for a resource.<br>The **$filter** is used to - /// reduce the set of metric data returned. Some common properties for this - /// expression will be: name.value, aggregationType, startTime, endTime, - /// timeGrain.<br>The filter expression uses these properties with - /// comparison operators (eg. eq, gt, lt) and multiple expressions can be - /// combined with parentheses and 'and/or' logical operators.<br>Some - /// example filter expressions are:<br>- $filter=(name.value eq - /// 'RunsSucceeded') and aggregationType eq 'Total' and startTime eq 2016-02-20 - /// and endTime eq 2016-02-21 and timeGrain eq duration'PT1M',<br>- - /// $filter=(name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or - /// aggregationType eq 'Average') and startTime eq 2016-02-20 and endTime eq - /// 2016-02-21 and timeGrain eq duration'PT1H',<br>- $filter=(name.value - /// eq 'ActionsCompleted' or name.value eq 'RunsSucceeded') and - /// (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime - /// eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - /// duration'PT1M'.<br><br> >**NOTE**: When a metrics query - /// comes in with multiple metrics, but with no aggregation types defined, the - /// service will pick the Primary aggregation type of the first metrics to be - /// used as the default aggregation type for all the metrics. + /// Lists the metric values for a resource. /// /// /// The identifier of the resource. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperationsExtensions.cs index 225269d53283..5c5557683781 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/MetricsOperationsExtensions.cs @@ -25,25 +25,7 @@ namespace Microsoft.Azure.Management.Monitor public static partial class MetricsOperationsExtensions { /// - /// Lists the metric values for a resource.<br>The **$filter** is used to - /// reduce the set of metric data returned. Some common properties for this - /// expression will be: name.value, aggregationType, startTime, endTime, - /// timeGrain.<br>The filter expression uses these properties with - /// comparison operators (eg. eq, gt, lt) and multiple expressions can be - /// combined with parentheses and 'and/or' logical operators.<br>Some - /// example filter expressions are:<br>- $filter=(name.value eq - /// 'RunsSucceeded') and aggregationType eq 'Total' and startTime eq 2016-02-20 - /// and endTime eq 2016-02-21 and timeGrain eq duration'PT1M',<br>- - /// $filter=(name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or - /// aggregationType eq 'Average') and startTime eq 2016-02-20 and endTime eq - /// 2016-02-21 and timeGrain eq duration'PT1H',<br>- $filter=(name.value - /// eq 'ActionsCompleted' or name.value eq 'RunsSucceeded') and - /// (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime - /// eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - /// duration'PT1M'.<br><br> >**NOTE**: When a metrics query - /// comes in with multiple metrics, but with no aggregation types defined, the - /// service will pick the Primary aggregation type of the first metrics to be - /// used as the default aggregation type for all the metrics. + /// Lists the metric values for a resource. /// /// /// The operations group for this extension method. @@ -60,25 +42,7 @@ public static partial class MetricsOperationsExtensions } /// - /// Lists the metric values for a resource.<br>The **$filter** is used to - /// reduce the set of metric data returned. Some common properties for this - /// expression will be: name.value, aggregationType, startTime, endTime, - /// timeGrain.<br>The filter expression uses these properties with - /// comparison operators (eg. eq, gt, lt) and multiple expressions can be - /// combined with parentheses and 'and/or' logical operators.<br>Some - /// example filter expressions are:<br>- $filter=(name.value eq - /// 'RunsSucceeded') and aggregationType eq 'Total' and startTime eq 2016-02-20 - /// and endTime eq 2016-02-21 and timeGrain eq duration'PT1M',<br>- - /// $filter=(name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or - /// aggregationType eq 'Average') and startTime eq 2016-02-20 and endTime eq - /// 2016-02-21 and timeGrain eq duration'PT1H',<br>- $filter=(name.value - /// eq 'ActionsCompleted' or name.value eq 'RunsSucceeded') and - /// (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime - /// eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - /// duration'PT1M'.<br><br> >**NOTE**: When a metrics query - /// comes in with multiple metrics, but with no aggregation types defined, the - /// service will pick the Primary aggregation type of the first metrics to be - /// used as the default aggregation type for all the metrics. + /// Lists the metric values for a resource. /// /// /// The operations group for this extension method. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperations.cs index f783b24c5bc3..bc5c38305e78 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperations.cs @@ -57,36 +57,19 @@ internal TenantActivityLogsOperations(MonitorClient client) /// applicable to this API (the parameters, $filter, etc.).<br>One thing /// to point out here is that this API does *not* retrieve the logs at the /// individual subscription of the tenant but only surfaces the logs that were - /// generated at the tenant level.<br>The **$filter** is very restricted - /// and allows only the following patterns.<br>- List events for a - /// resource group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- - /// List events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br>**NOTE**: No other - /// syntax is allowed. + /// generated at the tenant level. /// /// /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is a comma - /// separated list of property names to be returned. Possible values are: - /// authorization, channels, claims, correlationId, description, eventDataId, - /// eventName, eventTimestamp, httpRequest, level, operationId, operationName, - /// properties, resourceGroupName, resourceProviderName, resourceId, status, - /// submissionTimestamp, subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* /// /// /// Headers that will be added to request. @@ -265,25 +248,7 @@ internal TenantActivityLogsOperations(MonitorClient client) /// applicable to this API (the parameters, $filter, etc.).<br>One thing /// to point out here is that this API does *not* retrieve the logs at the /// individual subscription of the tenant but only surfaces the logs that were - /// generated at the tenant level.<br>The **$filter** is very restricted - /// and allows only the following patterns.<br>- List events for a - /// resource group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- - /// List events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br>**NOTE**: No other - /// syntax is allowed. + /// generated at the tenant level. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperationsExtensions.cs index 9e674c436af2..365a9db5a30f 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Monitor/TenantActivityLogsOperationsExtensions.cs @@ -28,25 +28,7 @@ public static partial class TenantActivityLogsOperationsExtensions /// applicable to this API (the parameters, $filter, etc.).<br>One thing /// to point out here is that this API does *not* retrieve the logs at the /// individual subscription of the tenant but only surfaces the logs that were - /// generated at the tenant level.<br>The **$filter** is very restricted - /// and allows only the following patterns.<br>- List events for a - /// resource group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- - /// List events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br>**NOTE**: No other - /// syntax is allowed. + /// generated at the tenant level. /// /// /// The operations group for this extension method. @@ -55,12 +37,13 @@ public static partial class TenantActivityLogsOperationsExtensions /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is a comma - /// separated list of property names to be returned. Possible values are: - /// authorization, channels, claims, correlationId, description, eventDataId, - /// eventName, eventTimestamp, httpRequest, level, operationId, operationName, - /// properties, resourceGroupName, resourceProviderName, resourceId, status, - /// submissionTimestamp, subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* /// public static IPage List(this ITenantActivityLogsOperations operations, ODataQuery odataQuery = default(ODataQuery), string select = default(string)) { @@ -73,25 +56,7 @@ public static partial class TenantActivityLogsOperationsExtensions /// applicable to this API (the parameters, $filter, etc.).<br>One thing /// to point out here is that this API does *not* retrieve the logs at the /// individual subscription of the tenant but only surfaces the logs that were - /// generated at the tenant level.<br>The **$filter** is very restricted - /// and allows only the following patterns.<br>- List events for a - /// resource group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- - /// List events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br>**NOTE**: No other - /// syntax is allowed. + /// generated at the tenant level. /// /// /// The operations group for this extension method. @@ -100,12 +65,13 @@ public static partial class TenantActivityLogsOperationsExtensions /// OData parameters to apply to the operation. /// /// - /// Used to fetch events with only the given properties. The filter is a comma - /// separated list of property names to be returned. Possible values are: - /// authorization, channels, claims, correlationId, description, eventDataId, - /// eventName, eventTimestamp, httpRequest, level, operationId, operationName, - /// properties, resourceGroupName, resourceProviderName, resourceId, status, - /// submissionTimestamp, subStatus, subscriptionId + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* /// /// /// The cancellation token. @@ -124,25 +90,7 @@ public static partial class TenantActivityLogsOperationsExtensions /// applicable to this API (the parameters, $filter, etc.).<br>One thing /// to point out here is that this API does *not* retrieve the logs at the /// individual subscription of the tenant but only surfaces the logs that were - /// generated at the tenant level.<br>The **$filter** is very restricted - /// and allows only the following patterns.<br>- List events for a - /// resource group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- - /// List events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br>**NOTE**: No other - /// syntax is allowed. + /// generated at the tenant level. /// /// /// The operations group for this extension method. @@ -161,25 +109,7 @@ public static IPage ListNext(this ITenantActivityLogsOperations opera /// applicable to this API (the parameters, $filter, etc.).<br>One thing /// to point out here is that this API does *not* retrieve the logs at the /// individual subscription of the tenant but only surfaces the logs that were - /// generated at the tenant level.<br>The **$filter** is very restricted - /// and allows only the following patterns.<br>- List events for a - /// resource group: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- - /// List events for resource: $filter=eventTimestamp ge '<Start Time>' - /// and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation' and resourceUri eq '<ResourceURI>'.<br>- List events - /// for a subscription: $filter=eventTimestamp ge '<Start Time>' and - /// eventTimestamp le '<End Time>' and eventChannels eq 'Admin, - /// Operation'.<br>- List evetns for a resource provider: - /// $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le - /// '<End Time>' and eventChannels eq 'Admin, Operation' and - /// resourceProvider eq '<ResourceProviderName>'.<br>- List events - /// for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge - /// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - /// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - /// correlationId eq '<CorrelationID>'.<br>**NOTE**: No other - /// syntax is allowed. + /// generated at the tenant level. /// /// /// The operations group for this extension method. 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 d2e1c7d848b2..9768403b35ca 100644 --- a/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj +++ b/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj @@ -2,9 +2,8 @@ Microsoft Azure Monitor Library - 0.16.0-preview Microsoft.Azure.Management.Monitor - + 0.16.1-preview Microsoft.Azure.Management.Monitor Management.Monitor;Management.Monitoring;metrics;alerts;autoscale;activityLogs;events;operations;logs diff --git a/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs b/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs index 1b7356e8f398..8ac46bc0d8c0 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.0.0")] -[assembly: AssemblyFileVersion("0.16.0.0")] +[assembly: AssemblyVersion("0.16.1.0")] +[assembly: AssemblyFileVersion("0.16.1.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Microsoft Azure .NET SDK")] diff --git a/src/SDKs/Monitor/Management.Monitor/generate.cmd b/src/SDKs/Monitor/Management.Monitor/generate.cmd index 79e4131db827..9df63e3394ed 100644 --- a/src/SDKs/Monitor/Management.Monitor/generate.cmd +++ b/src/SDKs/Monitor/Management.Monitor/generate.cmd @@ -6,13 +6,13 @@ @echo off if "%2" == "" ( - set specFile1="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0fde282c1aac0c9a07c35dd7054b3723bd890d45/monitor/compositeMonitorClient.json" + set specFile1="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5288e653adfe3dd6ce235a790008a8215eedb918/monitor/compositeMonitorClient.json" ) else ( set specFile1="%2" ) if "%3" == "" ( - set specFile2="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/186e73d857b8cad3336aed74f8959dc9dbcf8475/arm-monitor/compositeMonitorManagementClient.json" + set specFile2="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5288e653adfe3dd6ce235a790008a8215eedb918/arm-monitor/compositeMonitorManagementClient.json" ) else ( set specFile2="%3" ) diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/ActionGroupsTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/ActionGroupsTests.cs new file mode 100644 index 000000000000..17e4be4428cf --- /dev/null +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/ActionGroupsTests.cs @@ -0,0 +1,266 @@ +// 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.Linq; +using System.Net; +using System.Net.Http; +using Monitor.Tests.Helpers; +using Microsoft.Azure.Management.Monitor.Management; +using Microsoft.Azure.Management.Monitor.Management.Models; +using Xunit; +using Microsoft.Rest.Azure; + +namespace Monitor.Tests.BasicTests +{ + public class ActionGroupsTests : TestBase + { + [Fact] + public void CreateOrUpdateActionGroupTest() + { + ActionGroupResource expectedParameters = GetCreateOrUpdateActionGroupParameter(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters.Name + "\",\"id\":\"" + expectedParameters.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var result = insightsClient.ActionGroups.CreateOrUpdate(resourceGroupName: "rg1", actionGroupName: expectedParameters.Name, actionGroup: expectedParameters); + + AreEqual(expectedParameters, result); + } + + [Fact] + public void GetActionGroupTest() + { + var expectedActionGroup = GetCreateOrUpdateActionGroupParameter(name: "name4"); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedActionGroup, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedActionGroup.Name + "\",\"id\":\"" + expectedActionGroup.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var actionGroup = insightsClient.ActionGroups.Get( + resourceGroupName: "rg1", + actionGroupName: "name4"); + + AreEqual(expectedActionGroup, actionGroup); + } + + [Fact] + public void ListActionGroupsBySusbscriptionTest() + { + List expectedParameters = GetActionGroups(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters[0].Name + "\",\"id\":\"" + expectedParameters[0].Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var actualGroups = insightsClient.ActionGroups.ListBySubscriptionId(); + + AreEqual(expectedParameters.ToList(), actualGroups.ToList()); + } + + [Fact] + public void ListActionGroupsByResourceGroupTest() + { + List expectedParameters = GetActionGroups(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters[0].Name + "\",\"id\":\"" + expectedParameters[0].Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var actualGroups = insightsClient.ActionGroups.ListByResourceGroup(resourceGroupName: "rg1"); + + AreEqual(expectedParameters.ToList(), actualGroups.ToList()); + } + + [Fact] + public void DeleteActionGroupTest() + { + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK); + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + AzureOperationResponse response = monitorManagementClient.ActionGroups.DeleteWithHttpMessagesAsync( + resourceGroupName: " rg1", + actionGroupName: "name1").Result; + + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + } + + [Fact] + public void EnableActionGroupTest() + { + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK); + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + AzureOperationResponse response = monitorManagementClient.ActionGroups.EnableReceiverWithHttpMessagesAsync( + resourceGroupName: " rg1", + actionGroupName: "name1", + receiverName: "receiverName1").Result; + + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + } + + private static List GetActionGroups() + { + return new List + { + GetCreateOrUpdateActionGroupParameter(), + GetCreateOrUpdateActionGroupParameter(), + GetCreateOrUpdateActionGroupParameter() + }; + } + + private static void AreEqual(ActionGroupResource exp, ActionGroupResource act) + { + if (exp != null) + { + Assert.Equal(exp.Id, act.Id); + Assert.Equal(exp.Name, act.Name); + Assert.Equal(exp.Location, act.Location); + Assert.Equal(exp.GroupShortName, act.GroupShortName); + Assert.Equal(exp.Enabled, act.Enabled); + AreEqual(exp.Tags, act.Tags); + AreEqual(exp.EmailReceivers, act.EmailReceivers); + AreEqual(exp.SmsReceivers, act.SmsReceivers); + AreEqual(exp.WebhookReceivers, act.WebhookReceivers); + } + } + + private static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private static void AreEqual(EmailReceiver exp, EmailReceiver act) + { + if (exp != null) + { + Assert.Equal(exp.EmailAddress, act.EmailAddress); + Assert.Equal(exp.Name, act.Name); + Assert.Equal(exp.Status, act.Status); + } + } + + private static void AreEqual(SmsReceiver exp, SmsReceiver act) + { + if (exp != null) + { + Assert.Equal(exp.PhoneNumber, act.PhoneNumber); + Assert.Equal(exp.Name, act.Name); + Assert.Equal(exp.Status, act.Status); + } + } + + private static void AreEqual(WebhookReceiver exp, WebhookReceiver act) + { + if (exp != null) + { + Assert.Equal(exp.ServiceUri, act.ServiceUri); + Assert.Equal(exp.Name, act.Name); + } + } + + private static ActionGroupResource GetCreateOrUpdateActionGroupParameter( + string name = "name1", + List emailReceivers = null, + List smsReceivers = null, + List webhookReceivers = null) + { + // Name and id won't be serialized since they are readonly + return new ActionGroupResource( + id: "long name", + name: name, + location: "location", + groupShortName: name, + enabled: true, + tags: new Dictionary() + { + {"key1", "val1"} + }, + emailReceivers: emailReceivers, + smsReceivers: smsReceivers, + webhookReceivers: webhookReceivers + ); + } + } +} diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/ActivityLogAlertsTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/ActivityLogAlertsTests.cs new file mode 100644 index 000000000000..547190bf1f0f --- /dev/null +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/ActivityLogAlertsTests.cs @@ -0,0 +1,259 @@ +// 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.Linq; +using System.Net; +using System.Net.Http; +using Monitor.Tests.Helpers; +using Microsoft.Azure.Management.Monitor.Management; +using Microsoft.Azure.Management.Monitor.Management.Models; +using Xunit; +using Microsoft.Rest.Azure; + +namespace Monitor.Tests.BasicTests +{ + public class ActivityLogAlertsTests : TestBase + { + [Fact] + public void CreateOrUpdateActivityLogAlertsTest() + { + ActivityLogAlertResource expectedParameters = GetCreateOrUpdateActivityLogAlertParameter(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters.Name + "\",\"id\":\"" + expectedParameters.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var result = insightsClient.ActivityLogAlerts.CreateOrUpdate(resourceGroupName: "rg1", activityLogAlertName: expectedParameters.Name, activityLogAlert: expectedParameters); + + AreEqual(expectedParameters, result); + } + + [Fact] + public void GetActivityLogAlertTest() + { + var expectedActionGroup = GetCreateOrUpdateActivityLogAlertParameter(name: "name4"); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedActionGroup, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedActionGroup.Name + "\",\"id\":\"" + expectedActionGroup.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var activityLogAlert = insightsClient.ActivityLogAlerts.Get( + resourceGroupName: "rg1", + activityLogAlertName: "name4"); + + AreEqual(expectedActionGroup, activityLogAlert); + } + + [Fact] + public void ListActivityLogAlertsBySusbscriptionTest() + { + List expectedParameters = GetActionGroups(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters[0].Name + "\",\"id\":\"" + expectedParameters[0].Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var actualGroups = insightsClient.ActivityLogAlerts.ListBySubscriptionId(); + + AreEqual(expectedParameters, actualGroups.ToList()); + } + + [Fact] + public void ListActivityLogAlertsByResourceGroupTest() + { + List expectedParameters = GetActionGroups(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters[0].Name + "\",\"id\":\"" + expectedParameters[0].Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var actualGroups = insightsClient.ActivityLogAlerts.ListByResourceGroup(resourceGroupName: "rg1"); + + AreEqual(expectedParameters, actualGroups.ToList()); + } + + [Fact] + public void DeleteActivityLogAlertTest() + { + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK); + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + AzureOperationResponse response = monitorManagementClient.ActivityLogAlerts.DeleteWithHttpMessagesAsync( + resourceGroupName: " rg1", + activityLogAlertName: "name1").Result; + + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + } + + [Fact] + public void UpdateActivityLogAlertTest() + { + ActivityLogAlertResource expectedParameters = GetCreateOrUpdateActivityLogAlertParameter(); + + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, monitorManagementClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters.Name + "\",\"id\":\"" + expectedParameters.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + ActivityLogAlertPatchBody bodyParameter = new ActivityLogAlertPatchBody + { + Enabled = true, + Tags = null + }; + + ActivityLogAlertResource response = monitorManagementClient.ActivityLogAlerts.Update( + resourceGroupName: " rg1", + activityLogAlertName: "name1", + activityLogAlertPatch: bodyParameter); + + AreEqual(expectedParameters, response); + } + + private static List GetActionGroups() + { + return new List + { + GetCreateOrUpdateActivityLogAlertParameter(), + GetCreateOrUpdateActivityLogAlertParameter(), + GetCreateOrUpdateActivityLogAlertParameter() + }; + } + + private static void AreEqual(ActivityLogAlertResource exp, ActivityLogAlertResource act) + { + if (exp != null) + { + Assert.Equal(exp.Id, act.Id); + Assert.Equal(exp.Name, act.Name); + Assert.Equal(exp.Location, act.Location); + Assert.Equal(exp.Description, act.Description); + Assert.Equal(exp.Enabled, act.Enabled); + AreEqual(exp.Tags, act.Tags); + AreEqual(exp.Scopes, act.Scopes); + AreEqual(exp.Condition, act.Condition); + AreEqual(exp.Actions, act.Actions); + } + } + + private static void AreEqual(IList exp, IList act) + { + if (exp != null) + { + Assert.NotNull(act); + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private static void AreEqual(ActivityLogAlertAllOfCondition exp, ActivityLogAlertAllOfCondition act) + { + if (exp != null) + { + Assert.NotNull(act); + Assert.NotNull(act.AllOf); + for (int i = 0; i < exp.AllOf.Count; i++) + { + AreEqual(exp.AllOf[i], act.AllOf[i]); + } + } + } + + private static void AreEqual(ActivityLogAlertActionList exp, ActivityLogAlertActionList act) + { + if (exp != null) + { + Assert.NotNull(act); + Assert.NotNull(act.ActionGroups); + for (int i = 0; i < exp.ActionGroups.Count; i++) + { + AreEqual(exp.ActionGroups[i], act.ActionGroups[i]); + } + } + } + + private static void AreEqual(ActivityLogAlertActionGroup exp, ActivityLogAlertActionGroup act) + { + if (exp != null) + { + Assert.Equal(exp.ActionGroupId, act.ActionGroupId); + Assert.Equal(exp.WebhookProperties, act.WebhookProperties); + } + } + + private static void AreEqual(ActivityLogAlertLeafCondition exp, ActivityLogAlertLeafCondition act) + { + if (exp != null) + { + Assert.Equal(exp.Field, act.Field); + Assert.Equal(exp.Equals, act.Equals); + } + } + + private static ActivityLogAlertResource GetCreateOrUpdateActivityLogAlertParameter( + string name = "name1") + { + // Name and id won't be serialized since they are readonly + return new ActivityLogAlertResource( + id: "long name", + name: name, + location: "location", + tags: new Dictionary() + { + {"key1", "val1"} + }, + enabled: true, + description: "", + actions: new ActivityLogAlertActionList(new List { }), + condition: new ActivityLogAlertAllOfCondition(allOf: new List { }), + scopes: new List { "s1" } + ); + } + } +} diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/AlertsTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/AlertsTests.cs index 60ebd8d92567..c730606e9dbd 100644 --- a/src/SDKs/Monitor/Monitor.Tests/BasicTests/AlertsTests.cs +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/AlertsTests.cs @@ -15,6 +15,28 @@ namespace Monitor.Tests.BasicTests { public class AlertsTests : TestBase { + [Fact] + public void CreateOrUpdateRuleTest() + { + AlertRuleResource expectedParameters = GetCreateOrUpdateRuleParameter(); + + var handler = new RecordedDelegatingHandler(); + var insightsClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters.Name + "\",\"id\":\"" + expectedParameters.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightsClient = GetMonitorManagementClient(handler); + + var result = insightsClient.AlertRules.CreateOrUpdate(resourceGroupName: "rg1", ruleName: expectedParameters.Name, parameters: expectedParameters); + + AreEqual(expectedParameters, result); + } + [Fact] public void GetIncidentTest() { @@ -37,37 +59,6 @@ public void GetIncidentTest() AreEqual(expectedIncident, actualIncident); } - private static List GetIncidents() - { - return new List - { - new Incident( - activatedTime: DateTime.UtcNow, - isActive: false, - name: "i1", - resolvedTime: DateTime.UtcNow, - ruleName: "r1" - ) - }; - } - - private static void AreEqual(Incident exp, Incident act) - { - if (exp != null) - { - Assert.True(exp.ActivatedTime.HasValue); - Assert.True(act.ActivatedTime.HasValue); - Assert.Equal(exp.ActivatedTime.Value.ToUniversalTime(), act.ActivatedTime.Value.ToUniversalTime()); - Assert.Equal(exp.IsActive, act.IsActive); - Assert.Equal(exp.Name, act.Name); - - Assert.True(exp.ResolvedTime.HasValue); - Assert.True(act.ResolvedTime.HasValue); - Assert.Equal(exp.ResolvedTime.Value.ToUniversalTime(), act.ResolvedTime.Value.ToUniversalTime()); - Assert.Equal(exp.RuleName, act.RuleName); - } - } - [Fact] public void ListIncidentsTest() { @@ -97,71 +88,120 @@ public void ListIncidentsTest() AreEqual(expectedIncidentsResponse, actualIncidents.ToList()); } - private void AreEqual(IList exp, IList act) - { - if (exp != null) - { - for (int i = 0; i < exp.Count; i++) - { - AreEqual(exp[i], act[i]); - } - } - } - - private static void AreEqual(List exp, IList act) - { - if (exp != null) - { - for (int i = 0; i < exp.Count; i++) - { - AreEqual(exp[i], act[i]); - } - } - } - [Fact] - public void CreateOrUpdateRuleTest() + public void ListRulesTest() { - AlertRuleResource expectedParameters = GetCreateOrUpdateRuleParameter(); + var expResponse = GetRuleResourceCollection(); var handler = new RecordedDelegatingHandler(); var insightsClient = GetMonitorManagementClient(handler); - var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings); - serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters.Name + "\",\"id\":\"" + expectedParameters.Id + "\","); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expResponse, insightsClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expResponse[0].Name + "\",\"id\":\"" + expResponse[0].Id + "\","); var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) { - Content = new StringContent(serializedObject) + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) }; handler = new RecordedDelegatingHandler(expectedResponse); insightsClient = GetMonitorManagementClient(handler); - var result = insightsClient.AlertRules.CreateOrUpdate(resourceGroupName: "rg1", ruleName: expectedParameters.Name, parameters: expectedParameters); - - AreEqual(expectedParameters, result); + var actualResponse = insightsClient.AlertRules.ListByResourceGroup(resourceGroupName: " rg1"); + AreEqual(expResponse, actualResponse.ToList()); } [Fact] - public void ListRulesTest() + public void UpdateRulesTest() { - var expResponse = GetRuleResourceCollection(); + AlertRuleResource resource = GetRuleResourceCollection().FirstOrDefault(); + resource.IsEnabled = false; + resource.Tags = new Dictionary() + { + {"key2", "val2"} + }; var handler = new RecordedDelegatingHandler(); - var insightsClient = GetMonitorManagementClient(handler); - var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expResponse, insightsClient.SerializationSettings); - serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expResponse[0].Name + "\",\"id\":\"" + expResponse[0].Id + "\","); + var monitorManagementClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(resource, monitorManagementClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + resource.Name + "\",\"id\":\"" + resource.Id + "\","); var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) { - Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + Content = new StringContent(serializedObject) }; handler = new RecordedDelegatingHandler(expectedResponse); - insightsClient = GetMonitorManagementClient(handler); + monitorManagementClient = GetMonitorManagementClient(handler); - var actualResponse = insightsClient.AlertRules.ListByResourceGroup(resourceGroupName: " rg1"); - AreEqual(expResponse, actualResponse.ToList()); + AlertRuleResourcePatch pathResource = new AlertRuleResourcePatch( + name: resource.Name, + isEnabled: false, + tags: new Dictionary() + { + {"key2", "val2"} + }, + actions: resource.Actions, + condition: resource.Condition, + description: resource.Description, + lastUpdatedTime: resource.LastUpdatedTime + ); + + var actualResponse = monitorManagementClient.AlertRules.Update(resourceGroupName: " rg1", ruleName: resource.Name, alertRulesResource: pathResource); + AreEqual(resource, actualResponse); + } + + private static List GetIncidents() + { + return new List + { + new Incident( + activatedTime: DateTime.UtcNow, + isActive: false, + name: "i1", + resolvedTime: DateTime.UtcNow, + ruleName: "r1" + ) + }; } + private static void AreEqual(Incident exp, Incident act) + { + if (exp != null) + { + Assert.True(exp.ActivatedTime.HasValue); + Assert.True(act.ActivatedTime.HasValue); + Assert.Equal(exp.ActivatedTime.Value.ToUniversalTime(), act.ActivatedTime.Value.ToUniversalTime()); + Assert.Equal(exp.IsActive, act.IsActive); + Assert.Equal(exp.Name, act.Name); + + Assert.True(exp.ResolvedTime.HasValue); + Assert.True(act.ResolvedTime.HasValue); + Assert.Equal(exp.ResolvedTime.Value.ToUniversalTime(), act.ResolvedTime.Value.ToUniversalTime()); + Assert.Equal(exp.RuleName, act.RuleName); + } + } + + private void AreEqual(IList exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private static void AreEqual(List exp, IList act) + { + if (exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + } + + private void AreEqual(AlertRuleResource exp, AlertRuleResource act) { if (exp != null) diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/AutoscaleTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/AutoscaleTests.cs index 8ee63bcadd1e..4db66476bbae 100644 --- a/src/SDKs/Monitor/Monitor.Tests/BasicTests/AutoscaleTests.cs +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/AutoscaleTests.cs @@ -36,6 +36,44 @@ public void CreateOrUpdateSettingTest() AreEqual(expResponse, actualResponse); } + [Fact] + public void UpdateSettingTest() + { + AutoscaleSettingResource resource = CreateAutoscaleSetting(location: "East US", resourceUri: ResourceUri, metricName: "CpuPercentage"); + resource.Tags = new Dictionary + { + { "key2", "val2" } + }; + resource.Enabled = false; + + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(resource, monitorManagementClient.SerializationSettings); + serializedObject = serializedObject.Replace("{", "{\"name\":\"" + resource.Name + "\",\"id\":\"" + resource.Id + "\","); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + AutoscaleSettingResourcePatch pathResource = new AutoscaleSettingResourcePatch( + name: resource.Name, + tags: new Dictionary + { + { "key2", "val2" } + }, + notifications: resource.Notifications, + enabled: false, + profiles: resource.Profiles, + targetResourceUri: resource.TargetResourceUri + ); + + var actualResponse = monitorManagementClient.AutoscaleSettings.Update(resourceGroupName: "resourceGroup1", autoscaleSettingName: "setting1", autoscaleSettingResource: pathResource); + AreEqual(resource, actualResponse); + } + [Fact] public void Autoscale_GetSetting() { diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/LogProfilesTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/LogProfilesTests.cs index b49535fb5514..335ed456bf55 100644 --- a/src/SDKs/Monitor/Monitor.Tests/BasicTests/LogProfilesTests.cs +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/LogProfilesTests.cs @@ -99,6 +99,35 @@ public void LogProfiles_ListTest() AreEqual(expResponse[0], actualResponse[0]); } + [Fact] + public void LogProfiles_UpdateTest() + { + LogProfileResource resource = CreateLogProfile(); + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(resource, monitorManagementClient.SerializationSettings); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + LogProfileResourcePatch patchResource = new LogProfileResourcePatch( + locations: resource.Locations, + categories: resource.Categories, + retentionPolicy: resource.RetentionPolicy, + tags: resource.Tags, + serviceBusRuleId: resource.ServiceBusRuleId, + storageAccountId: resource.StorageAccountId + ); + + LogProfileResource actualResponse = monitorManagementClient.LogProfiles.Update(logProfileName: DefaultName, logProfilesResource: patchResource); + AreEqual(resource, actualResponse); + } + + private static LogProfileResource CreateLogProfile() { return new LogProfileResource diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs index 4c3a15911d91..540013a32a5e 100644 --- a/src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/ServiceDiagnosticSettingsTests.cs @@ -37,6 +37,35 @@ public void ServiceDiagnosticSettings_PutTest() AreEqual(expResponse, response); } + [Fact] + public void ServiceDiagnosticSettings_UpdateTest() + { + var resource = CreateDiagnosticSettings(); + var handler = new RecordedDelegatingHandler(); + var monitorManagementClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(resource, monitorManagementClient.SerializationSettings); + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + monitorManagementClient = GetMonitorManagementClient(handler); + + ServiceDiagnosticSettingsResourcePatch patchResource = new ServiceDiagnosticSettingsResourcePatch( + tags: resource.Tags, + storageAccountId: resource.StorageAccountId, + serviceBusRuleId: resource.ServiceBusRuleId, + eventHubAuthorizationRuleId: resource.EventHubAuthorizationRuleId, + metrics: resource.Metrics, + logs: resource.Logs, + workspaceId: resource.WorkspaceId + ); + + ServiceDiagnosticSettingsResource response = monitorManagementClient.ServiceDiagnosticSettings.Update(resourceUri: ResourceUri, serviceDiagnosticSettingsResource: patchResource); + AreEqual(resource, response); + } + [Fact] public void ServiceDiagnosticSettings_GetTest() { diff --git a/src/SDKs/Search/Build-SearchPackage.ps1 b/src/SDKs/Search/Build-SearchPackage.ps1 deleted file mode 100644 index ae4084fbcef8..000000000000 --- a/src/SDKs/Search/Build-SearchPackage.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent -msbuild "$scriptDir\..\..\build.proj" /t:"build;package" /p:scope=Search \ No newline at end of file diff --git a/src/SDKs/Search/Build-SearchPackages.ps1 b/src/SDKs/Search/Build-SearchPackages.ps1 new file mode 100644 index 000000000000..609ca5b4df62 --- /dev/null +++ b/src/SDKs/Search/Build-SearchPackages.ps1 @@ -0,0 +1,3 @@ +$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent +msbuild "$scriptDir\..\..\..\build.proj" /t:PublishNuget /p:Scope="SDKs\Search\Management" /p:NugetPackageName="Microsoft.Azure.Management.Search" +msbuild "$scriptDir\..\..\..\build.proj" /t:PublishNuget /p:Scope="SDKs\Search\DataPlane" /p:NugetPackageName="Microsoft.Azure.Search" diff --git a/src/SDKs/Search/Management/Management.Search/Management.Search.csproj b/src/SDKs/Search/Management/Management.Search/Microsoft.Azure.Management.Search.csproj similarity index 87% rename from src/SDKs/Search/Management/Management.Search/Management.Search.csproj rename to src/SDKs/Search/Management/Management.Search/Microsoft.Azure.Management.Search.csproj index 7a2e75bba95e..7fc3aca939ea 100644 --- a/src/SDKs/Search/Management/Management.Search/Management.Search.csproj +++ b/src/SDKs/Search/Management/Management.Search/Microsoft.Azure.Management.Search.csproj @@ -1,10 +1,10 @@  - Management.Search + Microsoft.Azure.Management.Search Makes it easy to manage Azure Search services and API keys from a .NET application. Microsoft Azure Search Management Library - Management.Search + Microsoft.Azure.Management.Search 1.0.2 Microsoft Azure Search;Microsoft Azure Search Management This is the Azure Search Management SDK for .NET, based on version 2015-08-19 of the Azure Search Management REST API. It includes support for programmatically provisioning and managing Search services and API keys. It supports all available SKUs, including the new S3 and S3 High-Density SKUs. diff --git a/src/SDKs/Search/Management/Search.Management.Tests/Search.Management.Tests.csproj b/src/SDKs/Search/Management/Search.Management.Tests/Search.Management.Tests.csproj index c6024220496b..d9e8514f1774 100644 --- a/src/SDKs/Search/Management/Search.Management.Tests/Search.Management.Tests.csproj +++ b/src/SDKs/Search/Management/Search.Management.Tests/Search.Management.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/SDKs/Search/Search.sln b/src/SDKs/Search/Search.sln index 563a51bb0d31..dee738e1772f 100644 --- a/src/SDKs/Search/Search.sln +++ b/src/SDKs/Search/Search.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Management.Search", "Management\Management.Search\Management.Search.csproj", "{A52AF58B-7383-416B-9A7E-601B9C628CDA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Management.Search", "Management\Management.Search\Microsoft.Azure.Management.Search.csproj", "{A52AF58B-7383-416B-9A7E-601B9C628CDA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Management", "Management", "{248E962E-D501-4153-8B38-459B7DCD6871}" EndProject