From 03d158cbd284f24ff3eab0a4a14af125e13cd556 Mon Sep 17 00:00:00 2001 From: Sanjay Pavan Chaluvadi Date: Thu, 31 May 2018 16:36:29 +0530 Subject: [PATCH 1/2] Add Metric Alert SDK --- src/SDKs/Monitor/AzSdk.RP.props | 2 +- .../Generated/IMetricAlertsOperations.cs | 171 +++ .../IMetricAlertsStatusOperations.cs | 80 ++ .../Generated/IMonitorManagementClient.cs | 10 + .../Generated/MetricAlertsOperations.cs | 1177 +++++++++++++++++ .../MetricAlertsOperationsExtensions.cs | 258 ++++ .../Generated/MetricAlertsStatusOperations.cs | 441 ++++++ .../MetricAlertsStatusOperationsExtensions.cs | 111 ++ .../Generated/Models/Action.cs | 32 + .../Generated/Models/MetricAlertAction.cs | 60 + .../Generated/Models/MetricAlertCriteria.cs | 55 + .../Generated/Models/MetricAlertResource.cs | 170 +++ .../Models/MetricAlertResourcePatch.cs | 171 +++ ...ertSingleResourceMultipleMetricCriteria.cs | 62 + .../Generated/Models/MetricAlertStatus.cs | 77 ++ .../Models/MetricAlertStatusCollection.cs | 56 + .../Models/MetricAlertStatusProperties.cs | 70 + .../Generated/Models/MetricCriteria.cs | 136 ++ .../Generated/Models/MetricDimension.cs | 88 ++ .../Generated/MonitorManagementClient.cs | 16 + .../Generated/SdkInfo_MonitorClient.cs | 37 +- .../Microsoft.Azure.Management.Monitor.csproj | 2 +- .../Properties/AssemblyInfo.cs | 4 +- .../Monitor/Management.Monitor/generate.ps1 | 1 + .../BasicTests/MetricAlertsTests.cs | 229 ++++ .../Monitor.Tests/Helpers/Utilities.cs | 184 +++ .../Scenarios/MetricAlertsTests.cs | 112 ++ .../MetricAlertRuleFlow.json | 273 ++++ src/SDKs/Monitor/changelog.md | 8 + 29 files changed, 4076 insertions(+), 17 deletions(-) create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsOperations.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsStatusOperations.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperations.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperationsExtensions.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperations.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperationsExtensions.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertCriteria.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResource.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResourcePatch.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatus.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusCollection.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs create mode 100644 src/SDKs/Monitor/Management.Monitor/generate.ps1 create mode 100644 src/SDKs/Monitor/Monitor.Tests/BasicTests/MetricAlertsTests.cs create mode 100644 src/SDKs/Monitor/Monitor.Tests/Scenarios/MetricAlertsTests.cs create mode 100644 src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MetricAlertRuleFlow.json diff --git a/src/SDKs/Monitor/AzSdk.RP.props b/src/SDKs/Monitor/AzSdk.RP.props index 0f80aaddead66..5500be0b0d04b 100644 --- a/src/SDKs/Monitor/AzSdk.RP.props +++ b/src/SDKs/Monitor/AzSdk.RP.props @@ -1,7 +1,7 @@ - insights_2017-04-01;insights_2015-04-01;insights_2016-03-01;insights_2017-05-01-preview;insights_2017-11-01-preview;insights_2018-01-01; + Insights_2018-03-01;insights_2017-04-01;insights_2015-04-01;insights_2016-03-01;insights_2017-05-01-preview;insights_2017-11-01-preview;insights_2018-01-01; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsOperations.cs new file mode 100644 index 0000000000000..c911c19fa704f --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsOperations.cs @@ -0,0 +1,171 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricAlertsOperations operations. + /// + public partial interface IMetricAlertsOperations + { + /// + /// Retrieve alert rule definitions 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve alert rule defintions 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)); + /// + /// Retrieve an alert rule definiton. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// 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 ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an metric alert definition. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or 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 ruleName, MetricAlertResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an metric alert definition. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an alert rule defitiniton. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// 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 ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsStatusOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsStatusOperations.cs new file mode 100644 index 0000000000000..292c2a96a8d3f --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IMetricAlertsStatusOperations.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricAlertsStatusOperations operations. + /// + public partial interface IMetricAlertsStatusOperations + { + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + /// + /// 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> ListByNameWithHttpMessagesAsync(string resourceGroupName, string ruleName, string statusName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IMonitorManagementClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IMonitorManagementClient.cs index a2683a480af5b..a2d658e1d0d65 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/IMonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IMonitorManagementClient.cs @@ -138,5 +138,15 @@ public partial interface IMonitorManagementClient : System.IDisposable /// IMetricBaselineOperations MetricBaseline { get; } + /// + /// Gets the IMetricAlertsOperations. + /// + IMetricAlertsOperations MetricAlerts { get; } + + /// + /// Gets the IMetricAlertsStatusOperations. + /// + IMetricAlertsStatusOperations MetricAlertsStatus { get; } + } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperations.cs new file mode 100644 index 0000000000000..3c37481548785 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperations.cs @@ -0,0 +1,1177 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + 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; + + /// + /// MetricAlertsOperations operations. + /// + internal partial class MetricAlertsOperations : IServiceOperations, IMetricAlertsOperations + { + /// + /// Initializes a new instance of the MetricAlertsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricAlertsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Retrieve alert rule definitions 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2018-03-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, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts").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; + } + + /// + /// Retrieve alert rule defintions 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 = "2018-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("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/metricAlerts").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; + } + + /// + /// Retrieve an alert rule definiton. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// 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 ruleName, 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"); + } + string apiVersion = "2018-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("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/metricAlerts/{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("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; + } + + /// + /// Create or update an metric alert definition. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or 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 ruleName, MetricAlertResource parameters, 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 (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-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("parameters", parameters); + 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/metricAlerts/{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("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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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; + } + + /// + /// Update an metric alert definition. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, 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 (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2018-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("parameters", parameters); + 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/metricAlerts/{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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, 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; + } + + /// + /// Delete an alert rule defitiniton. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// 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 ruleName, 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"); + } + string apiVersion = "2018-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("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/metricAlerts/{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("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; + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperationsExtensions.cs new file mode 100644 index 0000000000000..ba6c5599b9a18 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsOperationsExtensions.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. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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 MetricAlertsOperations. + /// + public static partial class MetricAlertsOperationsExtensions + { + /// + /// Retrieve alert rule definitions in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IMetricAlertsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Retrieve alert rule definitions in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IMetricAlertsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve alert rule defintions in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + public static IEnumerable ListByResourceGroup(this IMetricAlertsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve alert rule defintions 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 IMetricAlertsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve an alert rule definiton. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + public static MetricAlertResource Get(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName) + { + return operations.GetAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve an alert rule definiton. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + public static MetricAlertResource CreateOrUpdate(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to update. + /// + public static MetricAlertResource Update(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters) + { + return operations.UpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to update. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an alert rule defitiniton. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + public static void Delete(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Delete an alert rule defitiniton. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperations.cs new file mode 100644 index 0000000000000..2fc747a557515 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperations.cs @@ -0,0 +1,441 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + 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; + + /// + /// MetricAlertsStatusOperations operations. + /// + internal partial class MetricAlertsStatusOperations : IServiceOperations, IMetricAlertsStatusOperations + { + /// + /// Initializes a new instance of the MetricAlertsStatusOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricAlertsStatusOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceGroupName, string ruleName, 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"); + } + string apiVersion = "2018-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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status").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("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; + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + /// + /// 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> ListByNameWithHttpMessagesAsync(string resourceGroupName, string ruleName, string statusName, 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 (statusName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "statusName"); + } + string apiVersion = "2018-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("statusName", statusName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByName", 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/metricAlerts/{ruleName}/status/{statusName}").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)); + _url = _url.Replace("{statusName}", System.Uri.EscapeDataString(statusName)); + 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/MetricAlertsStatusOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperationsExtensions.cs new file mode 100644 index 0000000000000..9a5e5573db103 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/MetricAlertsStatusOperationsExtensions.cs @@ -0,0 +1,111 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MetricAlertsStatusOperations. + /// + public static partial class MetricAlertsStatusOperationsExtensions + { + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + public static MetricAlertStatusCollection List(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName) + { + return operations.ListAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + public static MetricAlertStatusCollection ListByName(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName, string statusName) + { + return operations.ListByNameAsync(resourceGroupName, ruleName, statusName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + /// + /// The cancellation token. + /// + public static async Task ListByNameAsync(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName, string statusName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByNameWithHttpMessagesAsync(resourceGroupName, ruleName, statusName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs new file mode 100644 index 0000000000000..dfc388c0a67a4 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using System.Linq; + + public partial class Action + { + /// + /// Initializes a new instance of the Action class. + /// + public Action() + { + CustomInit(); + } + + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs new file mode 100644 index 0000000000000..386f786f8a6c1 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An alert action. + /// + public partial class MetricAlertAction + { + /// + /// Initializes a new instance of the MetricAlertAction class. + /// + public MetricAlertAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertAction class. + /// + /// the id of the action group to + /// use. + public MetricAlertAction(string actionGroupId = default(string), IDictionary webhookProperties = default(IDictionary)) + { + ActionGroupId = actionGroupId; + WebhookProperties = webhookProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the id of the action group to use. + /// + [JsonProperty(PropertyName = "actionGroupId")] + public string ActionGroupId { get; set; } + + /// + /// + [JsonProperty(PropertyName = "webhookProperties")] + public IDictionary WebhookProperties { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertCriteria.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertCriteria.cs new file mode 100644 index 0000000000000..a3ba1b45aa0e7 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertCriteria.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The rule criteria that defines the conditions of the alert rule. + /// + public partial class MetricAlertCriteria + { + /// + /// Initializes a new instance of the MetricAlertCriteria class. + /// + public MetricAlertCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertCriteria class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + public MetricAlertCriteria(IDictionary additionalProperties = default(IDictionary)) + { + AdditionalProperties = additionalProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResource.cs new file mode 100644 index 0000000000000..827d420c64fb5 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResource.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. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The metric alert resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class MetricAlertResource : Resource + { + /// + /// Initializes a new instance of the MetricAlertResource class. + /// + public MetricAlertResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertResource class. + /// + /// Resource location + /// the description of the metric alert that + /// will be included in the alert email. + /// Alert severity {0, 1, 2, 3, 4} + /// the flag that indicates whether the metric + /// alert is enabled. + /// how often the metric alert is + /// evaluated represented in ISO 8601 duration format. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. + /// defines the specific alert criteria + /// information. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// the list of resource id's that this metric + /// alert is scoped to. + /// the flag that indicates whether the + /// alert should be auto resolved or not. + /// 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 MetricAlertResource(string location, string description, int severity, bool enabled, System.TimeSpan evaluationFrequency, System.TimeSpan windowSize, MetricAlertCriteria criteria, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList scopes = default(IList), bool? autoMitigate = default(bool?), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?)) + : base(location, id, name, type, tags) + { + Description = description; + Severity = severity; + Enabled = enabled; + Scopes = scopes; + EvaluationFrequency = evaluationFrequency; + WindowSize = windowSize; + Criteria = criteria; + AutoMitigate = autoMitigate; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the description of the metric alert that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets alert severity {0, 1, 2, 3, 4} + /// + [JsonProperty(PropertyName = "properties.severity")] + public int Severity { get; set; } + + /// + /// Gets or sets the flag that indicates whether the metric alert is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the list of resource id's that this metric alert is + /// scoped to. + /// + [JsonProperty(PropertyName = "properties.scopes")] + public IList Scopes { get; set; } + + /// + /// Gets or sets how often the metric alert is evaluated represented in + /// ISO 8601 duration format. + /// + [JsonProperty(PropertyName = "properties.evaluationFrequency")] + public System.TimeSpan EvaluationFrequency { get; set; } + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. + /// + [JsonProperty(PropertyName = "properties.windowSize")] + public System.TimeSpan WindowSize { get; set; } + + /// + /// Gets or sets defines the specific alert criteria information. + /// + [JsonProperty(PropertyName = "properties.criteria")] + public MetricAlertCriteria Criteria { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert should be + /// auto resolved or not. + /// + [JsonProperty(PropertyName = "properties.autoMitigate")] + public bool? AutoMitigate { 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 override void Validate() + { + base.Validate(); + if (Description == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Description"); + } + if (Criteria == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Criteria"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResourcePatch.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResourcePatch.cs new file mode 100644 index 0000000000000..2aed1b73414ea --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertResourcePatch.cs @@ -0,0 +1,171 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The metric alert resource for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class MetricAlertResourcePatch + { + /// + /// Initializes a new instance of the MetricAlertResourcePatch class. + /// + public MetricAlertResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertResourcePatch class. + /// + /// the description of the metric alert that + /// will be included in the alert email. + /// Alert severity {0, 1, 2, 3, 4} + /// the flag that indicates whether the metric + /// alert is enabled. + /// how often the metric alert is + /// evaluated represented in ISO 8601 duration format. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. + /// defines the specific alert criteria + /// information. + /// Resource tags + /// the list of resource id's that this metric + /// alert is scoped to. + /// the flag that indicates whether the + /// alert should be auto resolved or not. + /// 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 MetricAlertResourcePatch(string description, int severity, bool enabled, System.TimeSpan evaluationFrequency, System.TimeSpan windowSize, MetricAlertCriteria criteria, IDictionary tags = default(IDictionary), IList scopes = default(IList), bool? autoMitigate = default(bool?), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?)) + { + Tags = tags; + Description = description; + Severity = severity; + Enabled = enabled; + Scopes = scopes; + EvaluationFrequency = evaluationFrequency; + WindowSize = windowSize; + Criteria = criteria; + AutoMitigate = autoMitigate; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the description of the metric alert that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets alert severity {0, 1, 2, 3, 4} + /// + [JsonProperty(PropertyName = "properties.severity")] + public int Severity { get; set; } + + /// + /// Gets or sets the flag that indicates whether the metric alert is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the list of resource id's that this metric alert is + /// scoped to. + /// + [JsonProperty(PropertyName = "properties.scopes")] + public IList Scopes { get; set; } + + /// + /// Gets or sets how often the metric alert is evaluated represented in + /// ISO 8601 duration format. + /// + [JsonProperty(PropertyName = "properties.evaluationFrequency")] + public System.TimeSpan EvaluationFrequency { get; set; } + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. + /// + [JsonProperty(PropertyName = "properties.windowSize")] + public System.TimeSpan WindowSize { get; set; } + + /// + /// Gets or sets defines the specific alert criteria information. + /// + [JsonProperty(PropertyName = "properties.criteria")] + public MetricAlertCriteria Criteria { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert should be + /// auto resolved or not. + /// + [JsonProperty(PropertyName = "properties.autoMitigate")] + public bool? AutoMitigate { 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 (Description == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Description"); + } + if (Criteria == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Criteria"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs new file mode 100644 index 0000000000000..bc38badfd4b55 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the metric alert criteria for a single resource that has + /// multiple metric criteria. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria")] + public partial class MetricAlertSingleResourceMultipleMetricCriteria : MetricAlertCriteria + { + /// + /// Initializes a new instance of the + /// MetricAlertSingleResourceMultipleMetricCriteria class. + /// + public MetricAlertSingleResourceMultipleMetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MetricAlertSingleResourceMultipleMetricCriteria class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// The list of metric criteria for this 'all of' + /// operation. + public MetricAlertSingleResourceMultipleMetricCriteria(IDictionary additionalProperties = default(IDictionary), IList allOf = default(IList)) + : base(additionalProperties) + { + AllOf = allOf; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of metric criteria for this 'all of' + /// operation. + /// + [JsonProperty(PropertyName = "allOf")] + public IList AllOf { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatus.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatus.cs new file mode 100644 index 0000000000000..f09809a7535e2 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatus.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// An alert status. + /// + public partial class MetricAlertStatus + { + /// + /// Initializes a new instance of the MetricAlertStatus class. + /// + public MetricAlertStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertStatus class. + /// + /// The status name. + /// The alert rule arm id. + /// The extended resource type name. + /// The alert status properties of the metric + /// alert status. + public MetricAlertStatus(string name = default(string), string id = default(string), string type = default(string), MetricAlertStatusProperties properties = default(MetricAlertStatusProperties)) + { + Name = name; + Id = id; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the status name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the alert rule arm id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the extended resource type name. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the alert status properties of the metric alert + /// status. + /// + [JsonProperty(PropertyName = "properties")] + public MetricAlertStatusProperties Properties { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusCollection.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusCollection.cs new file mode 100644 index 0000000000000..461d2b441d0b9 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusCollection.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a collection of alert rule resources. + /// + public partial class MetricAlertStatusCollection + { + /// + /// Initializes a new instance of the MetricAlertStatusCollection + /// class. + /// + public MetricAlertStatusCollection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertStatusCollection + /// class. + /// + /// the values for the alert rule + /// resources. + public MetricAlertStatusCollection(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the values for the alert rule resources. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs new file mode 100644 index 0000000000000..8ae96d8cfc0e1 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An alert status properties. + /// + public partial class MetricAlertStatusProperties + { + /// + /// Initializes a new instance of the MetricAlertStatusProperties + /// class. + /// + public MetricAlertStatusProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertStatusProperties + /// class. + /// + /// status value + /// UTC time when the status was + /// checked. + public MetricAlertStatusProperties(IDictionary dimensions = default(IDictionary), string status = default(string), System.DateTime? timestamp = default(System.DateTime?)) + { + Dimensions = dimensions; + Status = status; + Timestamp = timestamp; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dimensions")] + public IDictionary Dimensions { get; set; } + + /// + /// Gets or sets status value + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets UTC time when the status was checked. + /// + [JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs new file mode 100644 index 0000000000000..53a98214ac8be --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs @@ -0,0 +1,136 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class MetricCriteria + { + /// + /// Initializes a new instance of the MetricCriteria class. + /// + public MetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricCriteria class. + /// + /// Name of the criteria. + /// Name of the metric. + /// the criteria operator. + /// the criteria time aggregation + /// types. + /// the criteria threshold value that activates + /// the alert. + /// Namespace of the metric. + /// List of dimension conditions. + public MetricCriteria(string name, string metricName, object operatorProperty, object timeAggregation, double threshold, string metricNamespace = default(string), IList dimensions = default(IList)) + { + Name = name; + MetricName = metricName; + MetricNamespace = metricNamespace; + OperatorProperty = operatorProperty; + TimeAggregation = timeAggregation; + Threshold = threshold; + Dimensions = dimensions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the criteria. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets name of the metric. + /// + [JsonProperty(PropertyName = "metricName")] + public string MetricName { get; set; } + + /// + /// Gets or sets namespace of the metric. + /// + [JsonProperty(PropertyName = "metricNamespace")] + public string MetricNamespace { get; set; } + + /// + /// Gets or sets the criteria operator. + /// + [JsonProperty(PropertyName = "operator")] + public object OperatorProperty { get; set; } + + /// + /// Gets or sets the criteria time aggregation types. + /// + [JsonProperty(PropertyName = "timeAggregation")] + public object TimeAggregation { get; set; } + + /// + /// Gets or sets the criteria threshold value that activates the alert. + /// + [JsonProperty(PropertyName = "threshold")] + public double Threshold { get; set; } + + /// + /// Gets or sets list of dimension conditions. + /// + [JsonProperty(PropertyName = "dimensions")] + public IList Dimensions { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (MetricName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MetricName"); + } + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (TimeAggregation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TimeAggregation"); + } + if (Dimensions != null) + { + foreach (var element in Dimensions) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs new file mode 100644 index 0000000000000..45c140c835957 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class MetricDimension + { + /// + /// Initializes a new instance of the MetricDimension class. + /// + public MetricDimension() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricDimension class. + /// + /// Name of the dimension. + /// the dimension operator. + /// list of dimension values. + public MetricDimension(string name, string operatorProperty, IList values) + { + Name = name; + OperatorProperty = operatorProperty; + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the dimension. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the dimension operator. + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets list of dimension values. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (Values == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Values"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs index 5f855f7993510..e7e42efa8f227 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs @@ -143,6 +143,16 @@ public partial class MonitorManagementClient : ServiceClient public virtual IMetricBaselineOperations MetricBaseline { get; private set; } + /// + /// Gets the IMetricAlertsOperations. + /// + public virtual IMetricAlertsOperations MetricAlerts { get; private set; } + + /// + /// Gets the IMetricAlertsStatusOperations. + /// + public virtual IMetricAlertsStatusOperations MetricAlertsStatus { get; private set; } + /// /// Initializes a new instance of the MonitorManagementClient class. /// @@ -359,6 +369,8 @@ private void Initialize() MetricDefinitions = new MetricDefinitionsOperations(this); Metrics = new MetricsOperations(this); MetricBaseline = new MetricBaselineOperations(this); + MetricAlerts = new MetricAlertsOperations(this); + MetricAlertsStatus = new MetricAlertsStatusOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; @@ -395,6 +407,10 @@ private void Initialize() DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs index faac10f754f79..705caf831a40b 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs @@ -1,16 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// -internal static partial class SdkInfo +namespace Microsoft.Azure.Management.Monitor { - public static IEnumerable> ApiInfo_MonitorClient - { - get - { - return new Tuple[] - { + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_MonitorClient + { + get + { + return new Tuple[] + { + new Tuple("Insights", "MetricAlerts", "2018-03-01"), + new Tuple("Insights", "MetricAlertsStatus", "2018-03-01"), new Tuple("insights", "ActionGroups", "2017-04-01"), new Tuple("insights", "ActivityLogAlerts", "2017-04-01"), new Tuple("insights", "ActivityLogs", "2015-04-01"), @@ -26,7 +36,8 @@ public static IEnumerable> ApiInfo_MonitorClient new Tuple("insights", "Metrics", "2018-01-01"), new Tuple("insights", "Operations", "2015-04-01"), new Tuple("insights", "TenantActivityLogs", "2015-04-01"), - }.AsEnumerable(); - } - } + }.AsEnumerable(); + } + } + } } 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 877cc06df4336..f655e4da36d2c 100644 --- a/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj +++ b/src/SDKs/Monitor/Management.Monitor/Microsoft.Azure.Management.Monitor.csproj @@ -6,7 +6,7 @@ Microsoft Azure Monitor Library Microsoft.Azure.Management.Monitor - 0.19.1-preview + 0.20.0-preview Microsoft.Azure.Management.Monitor Management.Monitor;Management.Monitoring;metrics;alerts;autoscale;activityLogs;events;operations;logs; See https://aka.ms/azure-sdk-for-net/monitor/changelog for release notes. diff --git a/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs b/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs index a7e13133812f4..706a4c3c6d9e1 100644 --- a/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs +++ b/src/SDKs/Monitor/Management.Monitor/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ [assembly: AssemblyTitle("Microsoft Azure Monitor Library")] [assembly: AssemblyDescription("Provides Microsoft Azure Monitor operations.")] -[assembly: AssemblyVersion("0.19.1.0")] -[assembly: AssemblyFileVersion("0.19.1.0")] +[assembly: AssemblyVersion("0.20.0.0")] +[assembly: AssemblyFileVersion("0.20.0.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Microsoft Azure .NET SDK")] diff --git a/src/SDKs/Monitor/Management.Monitor/generate.ps1 b/src/SDKs/Monitor/Management.Monitor/generate.ps1 new file mode 100644 index 0000000000000..f74b215cb8399 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/generate.ps1 @@ -0,0 +1 @@ +Start-AutoRestCodeGeneration -ResourceProvider "monitor/resource-manager" -AutoRestVersion "latest" \ No newline at end of file diff --git a/src/SDKs/Monitor/Monitor.Tests/BasicTests/MetricAlertsTests.cs b/src/SDKs/Monitor/Monitor.Tests/BasicTests/MetricAlertsTests.cs new file mode 100644 index 0000000000000..48e8be2841866 --- /dev/null +++ b/src/SDKs/Monitor/Monitor.Tests/BasicTests/MetricAlertsTests.cs @@ -0,0 +1,229 @@ +// 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; +using Microsoft.Azure.Management.Monitor.Models; +using Xunit; + +namespace Monitor.Tests.BasicTests +{ + public class MetricAlertsTests : TestBase + { + [Fact] + [Trait("Category", "Mock")] + public void CreateUpdateMetricAlertRuleTest() + { + MetricAlertResource expectedParams = GetSampleMetricRuleResourceParams(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParams, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var result = insightClient.MetricAlerts.CreateOrUpdate(resourceGroupName: "rg1", ruleName: "Rule1", parameters: expectedParams); + Utilities.AreEqual(expectedParams, result); + } + + [Fact] + [Trait("Category", "Mock")] + public void ListMetricAlertRuleByResourceGroupTest() + { + var expectedResponseValue = GetSampleMetricAlertCollection(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedResponseValue, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var actualResponse = insightClient.MetricAlerts.ListByResourceGroup(resourceGroupName: "rg1"); + Utilities.AreEqual(expectedResponseValue, actualResponse.ToList()); + } + + [Fact] + [Trait("Category", "Mock")] + public void ListMetricAlertsBySubscriptionTest() + { + var expectedResponseValue = GetSampleMetricAlertCollection(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedResponseValue, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(string.Concat("{ \"value\":", serializedObject, "}")) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var actualResponse = insightClient.MetricAlerts.ListBySubscription(); + Utilities.AreEqual(expectedResponseValue, actualResponse.ToList()); + } + + [Fact] + [Trait("Category", "Mock")] + public void GetMetricAlertStatusTest() + { + var expectedResponseValue = GetMetricAlertStatus(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedResponseValue, insightClient.SerializationSettings); + + var expcetedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expcetedResponse); + insightClient = GetMonitorManagementClient(handler); + + var actualResponse = insightClient.MetricAlertsStatus.List(resourceGroupName: "rg1", ruleName: "Rule1"); + Utilities.AreEqual(expectedResponseValue, actualResponse); + } + + [Fact] + [Trait("Category", "Mock")] + public void GetMetricAlertTest() + { + MetricAlertResource expectedParams = GetSampleMetricRuleResourceParams(); + var handler = new RecordedDelegatingHandler(); + var insightClient = GetMonitorManagementClient(handler); + var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParams, insightClient.SerializationSettings); + + var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(serializedObject) + }; + + handler = new RecordedDelegatingHandler(expectedResponse); + insightClient = GetMonitorManagementClient(handler); + + var result = insightClient.MetricAlerts.Get(resourceGroupName: "rg1", ruleName: "Rule1"); + Utilities.AreEqual(expectedParams, result); + } + + private MetricAlertStatusCollection GetMetricAlertStatus() + { + MetricAlertStatusProperties statusProps = new MetricAlertStatusProperties() + { + Dimensions = new Dictionary(), + Status = "Healthy", + Timestamp = new System.DateTime() + }; + + return new MetricAlertStatusCollection() + { + Value = new List() + { + new MetricAlertStatus(properties: statusProps) + } + }; + } + + private List GetSampleMetricAlertCollection() + { + return new List() + { + new MetricAlertResource( + description: "alert description", + severity: 3, + location: "Location", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + criteria: GetSampleMetricCriteria(), + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/custommetricdemo/providers/microsoft.insights/actiongroups/scactiongroup" + } + } + ) + }; + } + + private MetricAlertResource GetSampleMetricRuleResourceParams() + { + MetricAlertSingleResourceMultipleMetricCriteria metricCriteria = GetSampleMetricCriteria(); + + return new MetricAlertResource( + description: "alert description", + severity: 3, + location: "Location", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Compute/virtualMachines/SCCMDemo2" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 5, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/custommetricdemo/providers/microsoft.insights/actiongroups/scactiongroup" + } + } + ); + } + + private static MetricAlertSingleResourceMultipleMetricCriteria GetSampleMetricCriteria() + { + MetricDimension metricDimension = new MetricDimension() + { + Name = "name1", + OperatorProperty = "Include", + Values = new List() + { + "Primary" + } + }; + + MetricDimension[] metricDimensions = new MetricDimension[1] { metricDimension }; + + return new MetricAlertSingleResourceMultipleMetricCriteria( + allOf: new List() + { + new MetricCriteria() + { + MetricName = "Metric Name", + Name = "metric1", + Dimensions = metricDimensions, + Threshold = 100, + OperatorProperty = "GreaterThan", + TimeAggregation = "Avergage" + } + } + ); + } + } +} + + + + + diff --git a/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs b/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs index 1f1d32d695838..9f7ce1c8946d2 100644 --- a/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs +++ b/src/SDKs/Monitor/Monitor.Tests/Helpers/Utilities.cs @@ -641,5 +641,189 @@ private static void CompareLists(IList exp, IList act) } } #endregion + + #region MetricAlerts + public static void AreEqual(IList exp, IList act) + { + if(exp != null) + { + for(int i=0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricAlertResource exp, MetricAlertResource act) + { + if(exp != null) + { + Assert.Equal(exp.Description, act.Description); + Assert.Equal(exp.Location, act.Location); + Assert.Equal(exp.Severity, act.Severity); + Assert.Equal(exp.Enabled, act.Enabled); + AreEqual(exp.Scopes, act.Scopes); + Assert.Equal(exp.EvaluationFrequency, act.EvaluationFrequency); + Assert.Equal(exp.WindowSize, act.WindowSize); + AreEqual(exp.Criteria, act.Criteria); + Assert.Equal(exp.AutoMitigate, act.AutoMitigate); + AreEqual(exp.Actions, act.Actions); + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(IList exp, IList act) + { + if(exp != null) + { + for (int i = 0; i < exp.Count; i++) + { + AreEqual(exp[i], act[i]); + } + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricAlertAction exp, MetricAlertAction act) + { + if(exp != null) + { + Assert.Equal(exp.ActionGroupId, act.ActionGroupId); + AreEqual(exp.WebhookProperties, act.WebhookProperties); + + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricAlertCriteria exp, MetricAlertCriteria act) + { + if(exp != null) + { + if (exp.GetType() == typeof(MetricAlertSingleResourceMultipleMetricCriteria)) + { + Compare(exp as MetricAlertSingleResourceMultipleMetricCriteria, act as MetricAlertSingleResourceMultipleMetricCriteria); + } + } + else + { + Assert.Null(act); + } + } + + public static void Compare(MetricAlertSingleResourceMultipleMetricCriteria exp, MetricAlertSingleResourceMultipleMetricCriteria act) + { + if(exp != null) + { + for (int i = 0; i < exp.AllOf.Count; i++) + { + AreEqual(exp.AllOf[i], act.AllOf[i]); + } + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricCriteria exp, MetricCriteria act) + { + if(exp != null) + { + Assert.Equal(exp.MetricName, act.MetricName); + Assert.Equal(exp.Name, act.Name); + Assert.Equal(exp.MetricNamespace, act.MetricNamespace); + AreEqual(exp.Dimensions, act.Dimensions); + Assert.Equal(exp.OperatorProperty, act.OperatorProperty); + Assert.Equal(exp.TimeAggregation, act.TimeAggregation); + Assert.Equal(exp.Threshold, act.Threshold); + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(IList exp, IList act) + { + if(exp != null) + { + for(int i = 0; i < exp.Count; i++ ) + { + AreEqual(exp[i], act[i]); + } + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricDimension exp, MetricDimension act) + { + if(exp != null) + { + Assert.Equal(exp.Name, act.Name); + Assert.Equal(exp.OperatorProperty, act.OperatorProperty); + AreEqual(exp.Values, act.Values); + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricAlertStatusCollection exp, MetricAlertStatusCollection act) + { + if(exp != null) + { + for (int i = 0; i < exp.Value.Count; i++) + { + AreEqual(exp.Value[i], act.Value[i]); + } + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricAlertStatus exp, MetricAlertStatus act) + { + if(exp != null) + { + AreEqual(exp.Properties, act.Properties); + } + else + { + Assert.Null(act); + } + } + + public static void AreEqual(MetricAlertStatusProperties exp, MetricAlertStatusProperties act) + { + if(exp != null) + { + Assert.Equal(exp.Status, act.Status); + AreEqual(exp.Dimensions, act.Dimensions); + } + else + { + Assert.Null(act); + } + } + #endregion } } diff --git a/src/SDKs/Monitor/Monitor.Tests/Scenarios/MetricAlertsTests.cs b/src/SDKs/Monitor/Monitor.Tests/Scenarios/MetricAlertsTests.cs new file mode 100644 index 0000000000000..5d2cb36e1680b --- /dev/null +++ b/src/SDKs/Monitor/Monitor.Tests/Scenarios/MetricAlertsTests.cs @@ -0,0 +1,112 @@ +// 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 Monitor.Tests.Helpers; +using Microsoft.Azure.Management.Monitor; +using Microsoft.Azure.Management.Monitor.Models; +using Xunit; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using Microsoft.Rest.Azure; +using System.Globalization; + +namespace Monitor.Tests.Scenarios +{ + public class MetricAlertsTests : TestBase + { + private const string ResourceGroupName = "SanjaychResourceGroup"; + private const string RuleName = "MetricAlertSDKTestRule1"; + private const string ResourceId = "/subscriptions/{0}/resourceGroups/" + ResourceGroupName + "/providers/microsoft.insights/metricAlerts/" + RuleName; + private const string Location = "southcentralus"; + + private RecordedDelegatingHandler handler; + + public MetricAlertsTests() : base() + { + handler = new RecordedDelegatingHandler { SubsequentStatusCodeToReturn = HttpStatusCode.OK }; + } + + [Fact] + [Trait("Category", "Sceanrio")] + public void MetricAlertRuleFlow() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + MonitorManagementClient insightsClient = GetMonitorManagementClient(context, handler); + this.VerifyExistenceOrCreateResourceGroup(resourceGroupName: ResourceGroupName, location: Location); + + CreateOrUpdateMetricAlertRule(insightsClient); + GetMetricAlertRule(insightsClient); + DeleteMetricAlertRule(insightsClient); + } + } + + private void CreateOrUpdateMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateRuleParameters(); + MetricAlertResource result = insightsClient.MetricAlerts.CreateOrUpdate( + resourceGroupName: ResourceGroupName, + ruleName: RuleName, + parameters: expectedParameters); + + Utilities.AreEqual(expectedParameters, result); + } + + private void GetMetricAlertRule(MonitorManagementClient insightsClient) + { + MetricAlertResource expectedParameters = GetCreateOrUpdateRuleParameters(); + MetricAlertResource alertRule = insightsClient.MetricAlerts.Get(resourceGroupName: ResourceGroupName, ruleName: RuleName); + Utilities.AreEqual(expectedParameters, alertRule); + } + + private void DeleteMetricAlertRule(MonitorManagementClient insightsClient) + { + insightsClient.MetricAlerts.Delete(resourceGroupName: ResourceGroupName, ruleName: RuleName); + } + + private MetricAlertResource GetCreateOrUpdateRuleParameters() + { + MetricAlertSingleResourceMultipleMetricCriteria metricCriteria = new MetricAlertSingleResourceMultipleMetricCriteria( + allOf: new List() + { + new MetricCriteria() + { + MetricName = "Transactions", + MetricNamespace="Microsoft.Storage/storageAccounts", + Name = "metric1", + Dimensions = new MetricDimension[0], + Threshold = 100, + OperatorProperty = "GreaterThan", + TimeAggregation = "Total", + + } + } + ); + + return new MetricAlertResource( + description: " This is for Metric Alert SDK Scenario Test", + severity: 3, + location: "global", + enabled: true, + scopes: new List() + { + "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc" + }, + evaluationFrequency: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + windowSize: new TimeSpan(hours: 0, minutes: 15, seconds: 0), + criteria: metricCriteria, + actions: new List() + { + new MetricAlertAction() + { + ActionGroupId = "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup" + } + } + ); + } + + } +} diff --git a/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MetricAlertRuleFlow.json b/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MetricAlertRuleFlow.json new file mode 100644 index 0000000000000..5bcf380950ad1 --- /dev/null +++ b/src/SDKs/Monitor/Monitor.Tests/SessionRecords/Monitor.Tests.Scenarios.MetricAlertsTests/MetricAlertRuleFlow.json @@ -0,0 +1,273 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/SanjaychResourceGroup?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlZ3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cD9hcGktdmVyc2lvbj0yMDE3LTA1LTEw", + "RequestMethod": "HEAD", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "c29d9fb2-7f4c-433d-8356-b91755c4f8f6" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseBody": "", + "ResponseHeaders": { + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 05 Jun 2018 06:41:54 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14999" + ], + "x-ms-request-id": [ + "a9693c63-880a-4db1-bbda-2d245a78f35f" + ], + "x-ms-correlation-request-id": [ + "a9693c63-880a-4db1-bbda-2d245a78f35f" + ], + "x-ms-routing-request-id": [ + "SOUTHINDIA:20180605T064154Z:a9693c63-880a-4db1-bbda-2d245a78f35f" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 204 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MetricAlertSDKTestRule1?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NZXRyaWNBbGVydFNES1Rlc3RSdWxlMT9hcGktdmVyc2lvbj0yMDE4LTAzLTAx", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"description\": \" This is for Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"criteria\": {\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\",\r\n \"allOf\": [\r\n {\r\n \"name\": \"metric1\",\r\n \"metricName\": \"Transactions\",\r\n \"metricNamespace\": \"Microsoft.Storage/storageAccounts\",\r\n \"operator\": \"GreaterThan\",\r\n \"timeAggregation\": \"Total\",\r\n \"threshold\": 100.0,\r\n \"dimensions\": []\r\n }\r\n ]\r\n },\r\n \"actions\": [\r\n {\r\n \"odata.type\": \"Action\",\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup\"\r\n }\r\n ]\r\n },\r\n \"location\": \"global\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "1103" + ], + "x-ms-client-request-id": [ + "521c4833-4830-4a13-b6c1-0825c00c4826" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.20.0.0" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MetricAlertSDKTestRule1\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MetricAlertSDKTestRule1\",\r\n \"properties\": {\r\n \"description\": \" This is for Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"Microsoft.Storage/storageAccounts\",\r\n \"metricName\": \"Transactions\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"threshold\": 100.0,\r\n \"timeAggregation\": \"Total\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup\"\r\n }\r\n ]\r\n }\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 05 Jun 2018 06:42:16 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "Vary": [ + "Accept-Encoding" + ], + "x-ms-request-id": [ + "5f317981-dc22-46ee-a3d5-143bcaa5be5b" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "5f317981-dc22-46ee-a3d5-143bcaa5be5b" + ], + "x-ms-routing-request-id": [ + "SOUTHINDIA:20180605T064217Z:5f317981-dc22-46ee-a3d5-143bcaa5be5b" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MetricAlertSDKTestRule1?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NZXRyaWNBbGVydFNES1Rlc3RSdWxlMT9hcGktdmVyc2lvbj0yMDE4LTAzLTAx", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "7ae49bd2-2dc4-4fbe-9f93-bcf97600d24b" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.20.0.0" + ] + }, + "ResponseBody": "{\r\n \"location\": \"global\",\r\n \"type\": \"Microsoft.Insights/metricAlerts\",\r\n \"name\": \"MetricAlertSDKTestRule1\",\r\n \"id\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MetricAlertSDKTestRule1\",\r\n \"properties\": {\r\n \"description\": \" This is for Metric Alert SDK Scenario Test\",\r\n \"severity\": 3,\r\n \"enabled\": true,\r\n \"scopes\": [\r\n \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Storage/storageAccounts/metricalertsdktestacc\"\r\n ],\r\n \"evaluationFrequency\": \"PT15M\",\r\n \"windowSize\": \"PT15M\",\r\n \"templateType\": 8,\r\n \"criteria\": {\r\n \"allOf\": [\r\n {\r\n \"name\": \"metric1\",\r\n \"metricNamespace\": \"Microsoft.Storage/storageAccounts\",\r\n \"metricName\": \"Transactions\",\r\n \"dimensions\": [],\r\n \"operator\": \"GreaterThan\",\r\n \"threshold\": 100.0,\r\n \"timeAggregation\": \"Total\"\r\n }\r\n ],\r\n \"odata.type\": \"Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria\"\r\n },\r\n \"actions\": [\r\n {\r\n \"actionGroupId\": \"/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourcegroups/sanjaychresourcegroup/providers/microsoft.insights/actiongroups/scnewactiongroup\"\r\n }\r\n ]\r\n }\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 05 Jun 2018 06:42:37 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "Vary": [ + "Accept-Encoding" + ], + "x-ms-request-id": [ + "ff301bcd-03c0-486f-acc9-6ef79977d856" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14998" + ], + "x-ms-correlation-request-id": [ + "ff301bcd-03c0-486f-acc9-6ef79977d856" + ], + "x-ms-routing-request-id": [ + "SOUTHINDIA:20180605T064238Z:ff301bcd-03c0-486f-acc9-6ef79977d856" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/80430018-24ee-4b28-a7bd-fb23b5a221d6/resourceGroups/SanjaychResourceGroup/providers/Microsoft.Insights/metricAlerts/MetricAlertSDKTestRule1?api-version=2018-03-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODA0MzAwMTgtMjRlZS00YjI4LWE3YmQtZmIyM2I1YTIyMWQ2L3Jlc291cmNlR3JvdXBzL1NhbmpheWNoUmVzb3VyY2VHcm91cC9wcm92aWRlcnMvTWljcm9zb2Z0Lkluc2lnaHRzL21ldHJpY0FsZXJ0cy9NZXRyaWNBbGVydFNES1Rlc3RSdWxlMT9hcGktdmVyc2lvbj0yMDE4LTAzLTAx", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "09afcd7e-a111-46ff-ad12-f246fb3ca0f4" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.Monitor.MonitorManagementClient/0.20.0.0" + ] + }, + "ResponseBody": "", + "ResponseHeaders": { + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 05 Jun 2018 06:42:43 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "x-ms-request-id": [ + "f10cd352-9585-41a3-9f25-c241d7a4f4c0" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-correlation-request-id": [ + "f10cd352-9585-41a3-9f25-c241d7a4f4c0" + ], + "x-ms-routing-request-id": [ + "SOUTHINDIA:20180605T064244Z:f10cd352-9585-41a3-9f25-c241d7a4f4c0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "80430018-24ee-4b28-a7bd-fb23b5a221d6" + } +} \ No newline at end of file diff --git a/src/SDKs/Monitor/changelog.md b/src/SDKs/Monitor/changelog.md index 310d9cb2daee3..40174c84d4c87 100644 --- a/src/SDKs/Monitor/changelog.md +++ b/src/SDKs/Monitor/changelog.md @@ -1,5 +1,13 @@ ## Microsoft.Azure.Management.Monitor release notes +### Changes in 0.20.0-preview + +**Notes** + +- Approx. date of publication (2018-06) +- Adding MetricAlerts APIs and their unit tests +- Adding scenario tests for MetricAlerts and recorded them + ### Changes in 0.19.1-preview **Notes** From f1453fd677d9a671c3a7e1b1af0160aa01df2401 Mon Sep 17 00:00:00 2001 From: Sanjay Pavan Chaluvadi Date: Fri, 8 Jun 2018 09:59:26 +0530 Subject: [PATCH 2/2] Add commit txt file as per changes requestd for PR --- .../_metadata/monitor_resource-manager.txt | Bin 1244 -> 1465 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/SDKs/_metadata/monitor_resource-manager.txt b/src/SDKs/_metadata/monitor_resource-manager.txt index a227d0cbc313b67d41b5aa2fd439f1d8d3a1ff33..7b3044a3970e5fbbb4565ecd6b1818e9af62dfc6 100644 GIT binary patch literal 1465 zcmbtU%~IPi5Wedv_6C`b(Vn2Im>7_NtB3b^+Wb zE6e9POVAu&L~)bg^~I;S&5^w1G`v6;Tccv~*j;z`S_jmhEOl%6+A(%Z&$kV&BDkN3 zAP~Vfb~x=p=m!({oGPQOo;#RoQ|fjIf^B;zS5oBG+p>xQz@?VS-W&{)oqh+;IV!fH z@oB!jN;JjYZarL)mNrTnA3YVueo&{BCa7WQ0UWkvj*ogT=7$dsi(0{Oun*T2CffNC z)-NKl7zX^Ld5&KJN#e!~O_N_=4Ei->{p>MTx1ReW?oYrUM4=z`Cvfv+%7PxeL{2bR zYFm?VO)?`wNAf0^NC0#|b2YU}KxA?T>H!oqKJPG@z^8 z$2`u=oEhiupDX)m3oGo!T3gwZ-CJm9?p4|pO@ll{U)q|LV==dY_nI?CFYnM2Bq3U% zlva0sac39W5_xMCXcKG`qO5o?v7dqB(G%kSMk4P7to|Oo;zdX+JR@)_tP0Kqghyh| zxG6v7yTBuPwOQF6J_R~eSWT1o&)T1e@oSN61G5ef)BbIVl zqN&MfU!qLs_P`#IMM^`p_E^^axaDs;z={u}iRO20TG28O)+1~YR=>O0Lmf9GbfgQ4^ zHX@3o6DOJQ9wPZ>w|0SjY6rZwtLbNC6J^uW&}C9lm9q6c`h~ydQ!Li5JAF5U9TvmR z;(<&w$vuC8o#UtZE$EkYo3%YR0r~n_SL9v0G2KhS7%**P;tW{FoT|0p_7Uw2J`T}} z$&r1+dd9DC`V@Mk3Dt{~=DP lK8D2@W`_Jmj*-B=I?R4Hg{RDOs?v1o+j}qXz_BW3{{f`F))4>z