diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperations.cs index 861b627082da..24c568207943 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperations.cs @@ -105,7 +105,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -319,7 +319,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -505,7 +505,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -684,7 +684,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "actionGroupPatch"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -866,7 +866,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1044,7 +1044,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1189,7 +1189,8 @@ internal ActionGroupsOperations(MonitorManagementClient client) /// /// Enable a receiver in an action group. This changes the receiver's status - /// from Disabled to Enabled. + /// from Disabled to Enabled. This operation is only supported for Email or SMS + /// receivers. /// /// /// The name of the resource group. @@ -1236,7 +1237,7 @@ internal ActionGroupsOperations(MonitorManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "receiverName"); } - string apiVersion = "2017-04-01"; + string apiVersion = "2018-03-01"; EnableRequest enableRequest = new EnableRequest(); if (receiverName != null) { diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperationsExtensions.cs index b4f462b35ebf..4583e18a4624 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/ActionGroupsOperationsExtensions.cs @@ -258,7 +258,8 @@ public static IEnumerable ListByResourceGroup(this IActionG /// /// Enable a receiver in an action group. This changes the receiver's status - /// from Disabled to Enabled. + /// from Disabled to Enabled. This operation is only supported for Email or SMS + /// receivers. /// /// /// The operations group for this extension method. @@ -279,7 +280,8 @@ public static void EnableReceiver(this IActionGroupsOperations operations, strin /// /// Enable a receiver in an action group. This changes the receiver's status - /// from Disabled to Enabled. + /// from Disabled to Enabled. This operation is only supported for Email or SMS + /// receivers. /// /// /// The operations group for this extension method. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperations.cs index 4a3b43164550..be2b10a0420a 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperations.cs @@ -1049,5 +1049,181 @@ internal AlertRulesOperations(MonitorManagementClient client) return _result; } + /// + /// List the alert rules within 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 = "2016-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/alertrules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperationsExtensions.cs index 9745661176b1..ac299495db07 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/AlertRulesOperationsExtensions.cs @@ -228,5 +228,33 @@ public static IEnumerable ListByResourceGroup(this IAlertRule } } + /// + /// List the alert rules within a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IAlertRulesOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// List the alert rules within a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IAlertRulesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperations.cs index 802b18a5e2bb..2d2193992b4b 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperations.cs @@ -1016,6 +1016,177 @@ internal AutoscaleSettingsOperations(MonitorManagementClient client) return _result; } + /// + /// Lists the autoscale settings for 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 = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "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/autoscalesettings").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; + } + /// /// Lists the autoscale settings for a resource group /// @@ -1088,6 +1259,174 @@ internal AutoscaleSettingsOperations(MonitorManagementClient client) } + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + 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) diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperationsExtensions.cs index ee6900412848..c93ea91bbe53 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperationsExtensions.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/AutoscaleSettingsOperationsExtensions.cs @@ -226,6 +226,34 @@ public static AutoscaleSettingResource Update(this IAutoscaleSettingsOperations } } + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListBySubscription(this IAutoscaleSettingsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IAutoscaleSettingsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Lists the autoscale settings for a resource group /// @@ -260,5 +288,39 @@ public static IPage ListByResourceGroupNext(this IAuto } } + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IAutoscaleSettingsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this IAutoscaleSettingsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IActionGroupsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IActionGroupsOperations.cs index b120e4a24e13..9e85c5659aa7 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/IActionGroupsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IActionGroupsOperations.cs @@ -170,7 +170,8 @@ public partial interface IActionGroupsOperations Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Enable a receiver in an action group. This changes the receiver's - /// status from Disabled to Enabled. + /// status from Disabled to Enabled. This operation is only supported + /// for Email or SMS receivers. /// /// /// The name of the resource group. diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IAlertRulesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IAlertRulesOperations.cs index 25a7cfceaf50..5f788567851b 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/IAlertRulesOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IAlertRulesOperations.cs @@ -149,5 +149,24 @@ public partial interface IAlertRulesOperations /// Thrown when a required parameter is null /// Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the alert rules within 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)); } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IAutoscaleSettingsOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IAutoscaleSettingsOperations.cs index 70c80c540ff6..f19a2533a788 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/IAutoscaleSettingsOperations.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IAutoscaleSettingsOperations.cs @@ -150,6 +150,25 @@ public partial interface IAutoscaleSettingsOperations /// Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Lists the autoscale settings for 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)); + /// /// Lists the autoscale settings for a resource group /// /// @@ -171,5 +190,27 @@ public partial interface IAutoscaleSettingsOperations /// Thrown when a required parameter is null /// Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, 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 a2d658e1d0d6..9644c43ef343 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/IMonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IMonitorManagementClient.cs @@ -46,19 +46,20 @@ public partial interface IMonitorManagementClient : System.IDisposable string SubscriptionId { get; set; } /// - /// Gets or sets the preferred language for the response. + /// The preferred language for the response. /// string AcceptLanguage { get; set; } /// - /// Gets or sets the retry timeout in seconds for Long Running - /// Operations. Default value is 30. + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. /// int? LongRunningOperationRetryTimeout { get; set; } /// - /// When set to true a unique x-ms-client-request-id value is generated - /// and included in each request. Default is true. + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. /// bool? GenerateClientRequestId { get; set; } @@ -148,5 +149,10 @@ public partial interface IMonitorManagementClient : System.IDisposable /// IMetricAlertsStatusOperations MetricAlertsStatus { get; } + /// + /// Gets the IScheduledQueryRulesOperations. + /// + IScheduledQueryRulesOperations ScheduledQueryRules { get; } + } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/IScheduledQueryRulesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/IScheduledQueryRulesOperations.cs new file mode 100644 index 000000000000..ba4456ae5c1e --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/IScheduledQueryRulesOperations.cs @@ -0,0 +1,178 @@ +// +// 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 Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ScheduledQueryRulesOperations operations. + /// + public partial interface IScheduledQueryRulesOperations + { + /// + /// Creates or updates an log search rule. + /// + /// + /// 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, LogSearchRuleResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an Log Search rule + /// + /// + /// 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)); + /// + /// Update log search Rule. + /// + /// + /// 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, LogSearchRuleResourcePatch parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a Log Search rule + /// + /// + /// 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)); + /// + /// List the Log Search rules within a subscription group. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the Log Search rules within a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs index dfc388c0a67a..31f552c14562 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Action.cs @@ -12,6 +12,9 @@ namespace Microsoft.Azure.Management.Monitor.Models { using System.Linq; + /// + /// Action descriptor. + /// public partial class Action { /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/ActionGroupResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/ActionGroupResource.cs index b469ce2befcc..4317bcb0e339 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/ActionGroupResource.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/ActionGroupResource.cs @@ -57,7 +57,13 @@ public ActionGroupResource() /// The list of /// AutomationRunbook receivers that are part of this action /// group. - public ActionGroupResource(string location, string groupShortName, bool enabled, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList emailReceivers = default(IList), IList smsReceivers = default(IList), IList webhookReceivers = default(IList), IList itsmReceivers = default(IList), IList azureAppPushReceivers = default(IList), IList automationRunbookReceivers = default(IList)) + /// The list of voice receivers that are + /// part of this action group. + /// The list of logic app receivers + /// that are part of this action group. + /// The list of azure function + /// receivers that are part of this action group. + public ActionGroupResource(string location, string groupShortName, bool enabled, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList emailReceivers = default(IList), IList smsReceivers = default(IList), IList webhookReceivers = default(IList), IList itsmReceivers = default(IList), IList azureAppPushReceivers = default(IList), IList automationRunbookReceivers = default(IList), IList voiceReceivers = default(IList), IList logicAppReceivers = default(IList), IList azureFunctionReceivers = default(IList)) : base(location, id, name, type, tags) { GroupShortName = groupShortName; @@ -68,6 +74,9 @@ public ActionGroupResource() ItsmReceivers = itsmReceivers; AzureAppPushReceivers = azureAppPushReceivers; AutomationRunbookReceivers = automationRunbookReceivers; + VoiceReceivers = voiceReceivers; + LogicAppReceivers = logicAppReceivers; + AzureFunctionReceivers = azureFunctionReceivers; CustomInit(); } @@ -133,6 +142,27 @@ public ActionGroupResource() [JsonProperty(PropertyName = "properties.automationRunbookReceivers")] public IList AutomationRunbookReceivers { get; set; } + /// + /// Gets or sets the list of voice receivers that are part of this + /// action group. + /// + [JsonProperty(PropertyName = "properties.voiceReceivers")] + public IList VoiceReceivers { get; set; } + + /// + /// Gets or sets the list of logic app receivers that are part of this + /// action group. + /// + [JsonProperty(PropertyName = "properties.logicAppReceivers")] + public IList LogicAppReceivers { get; set; } + + /// + /// Gets or sets the list of azure function receivers that are part of + /// this action group. + /// + [JsonProperty(PropertyName = "properties.azureFunctionReceivers")] + public IList AzureFunctionReceivers { get; set; } + /// /// Validate the object. /// @@ -148,9 +178,9 @@ public override void Validate() } if (GroupShortName != null) { - if (GroupShortName.Length > 15) + if (GroupShortName.Length > 12) { - throw new ValidationException(ValidationRules.MaxLength, "GroupShortName", 15); + throw new ValidationException(ValidationRules.MaxLength, "GroupShortName", 12); } } if (EmailReceivers != null) @@ -213,6 +243,36 @@ public override void Validate() } } } + if (VoiceReceivers != null) + { + foreach (var element6 in VoiceReceivers) + { + if (element6 != null) + { + element6.Validate(); + } + } + } + if (LogicAppReceivers != null) + { + foreach (var element7 in LogicAppReceivers) + { + if (element7 != null) + { + element7.Validate(); + } + } + } + if (AzureFunctionReceivers != null) + { + foreach (var element8 in AzureFunctionReceivers) + { + if (element8 != null) + { + element8.Validate(); + } + } + } } } } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/AlertSeverity.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AlertSeverity.cs new file mode 100644 index 000000000000..61b755cfc3d7 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AlertSeverity.cs @@ -0,0 +1,25 @@ +// +// 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 +{ + + /// + /// Defines values for AlertSeverity. + /// + public static class AlertSeverity + { + public const string Zero = "0"; + public const string One = "1"; + public const string Two = "2"; + public const string Three = "3"; + public const string Four = "4"; + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/AlertingAction.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AlertingAction.cs new file mode 100644 index 000000000000..c8e9e2054e8b --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AlertingAction.cs @@ -0,0 +1,108 @@ +// +// 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.Linq; + + /// + /// Specifiy action need to be taken when rule type is Alert + /// + [Newtonsoft.Json.JsonObject("Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction")] + public partial class AlertingAction : Action + { + /// + /// Initializes a new instance of the AlertingAction class. + /// + public AlertingAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertingAction class. + /// + /// Severity of the alert. Possible values + /// include: '0', '1', '2', '3', '4' + /// Azure action group reference. + /// The trigger condition that results in the + /// alert rule being. + /// time (in minutes) for which Alerts + /// should be throttled or suppressed. + public AlertingAction(string severity, AzNsActionGroup aznsAction, TriggerCondition trigger, int? throttlingInMin = default(int?)) + { + Severity = severity; + AznsAction = aznsAction; + ThrottlingInMin = throttlingInMin; + Trigger = trigger; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets severity of the alert. Possible values include: '0', + /// '1', '2', '3', '4' + /// + [JsonProperty(PropertyName = "severity")] + public string Severity { get; set; } + + /// + /// Gets or sets azure action group reference. + /// + [JsonProperty(PropertyName = "aznsAction")] + public AzNsActionGroup AznsAction { get; set; } + + /// + /// Gets or sets time (in minutes) for which Alerts should be throttled + /// or suppressed. + /// + [JsonProperty(PropertyName = "throttlingInMin")] + public int? ThrottlingInMin { get; set; } + + /// + /// Gets or sets the trigger condition that results in the alert rule + /// being. + /// + [JsonProperty(PropertyName = "trigger")] + public TriggerCondition Trigger { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Severity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Severity"); + } + if (AznsAction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AznsAction"); + } + if (Trigger == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Trigger"); + } + if (Trigger != null) + { + Trigger.Validate(); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/AzNsActionGroup.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AzNsActionGroup.cs new file mode 100644 index 000000000000..5a8dadef71e5 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AzNsActionGroup.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// 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; + + /// + /// Azure action group + /// + public partial class AzNsActionGroup + { + /// + /// Initializes a new instance of the AzNsActionGroup class. + /// + public AzNsActionGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzNsActionGroup class. + /// + /// Azure Action Group reference. + /// Custom subject override for all email + /// ids in Azure action group + /// Custom payload to be sent for + /// all webook URI in Azure action group + public AzNsActionGroup(IList actionGroup = default(IList), string emailSubject = default(string), string customWebhookPayload = default(string)) + { + ActionGroup = actionGroup; + EmailSubject = emailSubject; + CustomWebhookPayload = customWebhookPayload; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure Action Group reference. + /// + [JsonProperty(PropertyName = "actionGroup")] + public IList ActionGroup { get; set; } + + /// + /// Gets or sets custom subject override for all email ids in Azure + /// action group + /// + [JsonProperty(PropertyName = "emailSubject")] + public string EmailSubject { get; set; } + + /// + /// Gets or sets custom payload to be sent for all webook URI in Azure + /// action group + /// + [JsonProperty(PropertyName = "customWebhookPayload")] + public string CustomWebhookPayload { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/AzureFunctionReceiver.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AzureFunctionReceiver.cs new file mode 100644 index 000000000000..e1f6536f30d1 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/AzureFunctionReceiver.cs @@ -0,0 +1,106 @@ +// +// 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.Linq; + + /// + /// An azure function receiver. + /// + public partial class AzureFunctionReceiver + { + /// + /// Initializes a new instance of the AzureFunctionReceiver class. + /// + public AzureFunctionReceiver() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureFunctionReceiver class. + /// + /// The name of the azure function receiver. Names + /// must be unique across all receivers within an action group. + /// The azure resource id of the + /// function app. + /// The function name in the function + /// app. + /// The http trigger url where http + /// request sent to. + public AzureFunctionReceiver(string name, string functionAppResourceId, string functionName, string httpTriggerUrl) + { + Name = name; + FunctionAppResourceId = functionAppResourceId; + FunctionName = functionName; + HttpTriggerUrl = httpTriggerUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the azure function receiver. Names must be + /// unique across all receivers within an action group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the azure resource id of the function app. + /// + [JsonProperty(PropertyName = "functionAppResourceId")] + public string FunctionAppResourceId { get; set; } + + /// + /// Gets or sets the function name in the function app. + /// + [JsonProperty(PropertyName = "functionName")] + public string FunctionName { get; set; } + + /// + /// Gets or sets the http trigger url where http request sent to. + /// + [JsonProperty(PropertyName = "httpTriggerUrl")] + public string HttpTriggerUrl { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (FunctionAppResourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "FunctionAppResourceId"); + } + if (FunctionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "FunctionName"); + } + if (HttpTriggerUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "HttpTriggerUrl"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/ConditionalOperator.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/ConditionalOperator.cs new file mode 100644 index 000000000000..98d5f8fd2d69 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/ConditionalOperator.cs @@ -0,0 +1,23 @@ +// +// 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 +{ + + /// + /// Defines values for ConditionalOperator. + /// + public static class ConditionalOperator + { + public const string GreaterThan = "GreaterThan"; + public const string LessThan = "LessThan"; + public const string Equal = "Equal"; + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/DiagnosticSettingsResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/DiagnosticSettingsResource.cs index 0c4f6f6d3678..b80c7d9eac49 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/DiagnosticSettingsResource.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/DiagnosticSettingsResource.cs @@ -39,6 +39,9 @@ public DiagnosticSettingsResource() /// Azure resource type /// The resource ID of the storage /// account to which you would like to send Diagnostic Logs. + /// The service bus rule Id of the + /// diagnostic setting. This is here to maintain backwards + /// compatibility. /// The resource Id for the /// event hub authorization rule. /// The name of the event hub. If none is @@ -49,10 +52,11 @@ public DiagnosticSettingsResource() /// Analytics workspace) for a Log Analytics workspace to which you /// would like to send Diagnostic Logs. Example: /// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 - public DiagnosticSettingsResource(string id = default(string), string name = default(string), string type = default(string), string storageAccountId = default(string), string eventHubAuthorizationRuleId = default(string), string eventHubName = default(string), IList metrics = default(IList), IList logs = default(IList), string workspaceId = default(string)) + public DiagnosticSettingsResource(string id = default(string), string name = default(string), string type = default(string), string storageAccountId = default(string), string serviceBusRuleId = default(string), string eventHubAuthorizationRuleId = default(string), string eventHubName = default(string), IList metrics = default(IList), IList logs = default(IList), string workspaceId = default(string)) : base(id, name, type) { StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; EventHubAuthorizationRuleId = eventHubAuthorizationRuleId; EventHubName = eventHubName; Metrics = metrics; @@ -73,6 +77,13 @@ public DiagnosticSettingsResource() [JsonProperty(PropertyName = "properties.storageAccountId")] public string StorageAccountId { get; set; } + /// + /// Gets or sets the service bus rule Id of the diagnostic setting. + /// This is here to maintain backwards compatibility. + /// + [JsonProperty(PropertyName = "properties.serviceBusRuleId")] + public string ServiceBusRuleId { get; set; } + /// /// Gets or sets the resource Id for the event hub authorization rule. /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Enabled.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Enabled.cs new file mode 100644 index 000000000000..6620ddddeea6 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Enabled.cs @@ -0,0 +1,22 @@ +// +// 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 +{ + + /// + /// Defines values for Enabled. + /// + public static class Enabled + { + public const string True = "true"; + public const string False = "false"; + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/EventData.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/EventData.cs index 38533edbd367..91dc9e9d304d 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/EventData.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/EventData.cs @@ -31,6 +31,8 @@ public EventData() /// /// Initializes a new instance of the EventData class. /// + /// The sender authorization + /// information. /// key value pairs to identify ARM /// permissions. /// the email address of the user who has @@ -126,6 +128,7 @@ public EventData() partial void CustomInit(); /// + /// Gets the sender authorization information. /// [JsonProperty(PropertyName = "authorization")] public SenderAuthorization Authorization { get; private set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogMetricTrigger.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogMetricTrigger.cs new file mode 100644 index 000000000000..6c0adfc1c88d --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogMetricTrigger.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// 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; + + /// + /// A log metrics trigger descriptor. + /// + public partial class LogMetricTrigger + { + /// + /// Initializes a new instance of the LogMetricTrigger class. + /// + public LogMetricTrigger() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogMetricTrigger class. + /// + /// Evaluation operation for Metric + /// -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + /// 'GreaterThan', 'LessThan', 'Equal' + /// The threshold of the metric + /// trigger. + /// Metric Trigger Type - 'Consecutive' + /// or 'Total'. Possible values include: 'Consecutive', 'Total' + /// Evaluation of metric on a particular + /// column + public LogMetricTrigger(string thresholdOperator = default(string), double? threshold = default(double?), string metricTriggerType = default(string), string metricColumn = default(string)) + { + ThresholdOperator = thresholdOperator; + Threshold = threshold; + MetricTriggerType = metricTriggerType; + MetricColumn = metricColumn; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets evaluation operation for Metric -'GreaterThan' or + /// 'LessThan' or 'Equal'. Possible values include: 'GreaterThan', + /// 'LessThan', 'Equal' + /// + [JsonProperty(PropertyName = "thresholdOperator")] + public string ThresholdOperator { get; set; } + + /// + /// Gets or sets the threshold of the metric trigger. + /// + [JsonProperty(PropertyName = "threshold")] + public double? Threshold { get; set; } + + /// + /// Gets or sets metric Trigger Type - 'Consecutive' or 'Total'. + /// Possible values include: 'Consecutive', 'Total' + /// + [JsonProperty(PropertyName = "metricTriggerType")] + public string MetricTriggerType { get; set; } + + /// + /// Gets or sets evaluation of metric on a particular column + /// + [JsonProperty(PropertyName = "metricColumn")] + public string MetricColumn { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogSearchRuleResource.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogSearchRuleResource.cs new file mode 100644 index 000000000000..e3145a6c63c7 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogSearchRuleResource.cs @@ -0,0 +1,152 @@ +// +// 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 Log Search Rule resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class LogSearchRuleResource : Resource + { + /// + /// Initializes a new instance of the LogSearchRuleResource class. + /// + public LogSearchRuleResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogSearchRuleResource class. + /// + /// Resource location + /// Data Source against which rule will Query + /// Data + /// Schedule (Frequnecy, Time Window) for + /// rule. + /// Action needs to be taken on rule + /// execution. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// The description of the Log Search + /// rule. + /// The flag which indicates whether the Log + /// Search rule is enabled. Value should be true or false. Possible + /// values include: 'true', 'false' + /// Last time the rule was updated in + /// IS08601 format. + /// Provisioning state of the + /// scheduledquery rule. Possible values include: 'Succeeded', + /// 'Deploying', 'Canceled', 'Failed' + public LogSearchRuleResource(string location, Source source, Schedule schedule, Action action, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string description = default(string), string enabled = default(string), System.DateTime? lastUpdatedTime = default(System.DateTime?), string provisioningState = default(string)) + : base(location, id, name, type, tags) + { + Description = description; + Enabled = enabled; + LastUpdatedTime = lastUpdatedTime; + ProvisioningState = provisioningState; + Source = source; + Schedule = schedule; + Action = action; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the description of the Log Search rule. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the flag which indicates whether the Log Search rule + /// is enabled. Value should be true or false. Possible values include: + /// 'true', 'false' + /// + [JsonProperty(PropertyName = "properties.enabled")] + public string Enabled { get; set; } + + /// + /// Gets last time the rule was updated in IS08601 format. + /// + [JsonProperty(PropertyName = "properties.lastUpdatedTime")] + public System.DateTime? LastUpdatedTime { get; private set; } + + /// + /// Gets provisioning state of the scheduledquery rule. Possible values + /// include: 'Succeeded', 'Deploying', 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets data Source against which rule will Query Data + /// + [JsonProperty(PropertyName = "properties.source")] + public Source Source { get; set; } + + /// + /// Gets or sets schedule (Frequnecy, Time Window) for rule. + /// + [JsonProperty(PropertyName = "properties.schedule")] + public Schedule Schedule { get; set; } + + /// + /// Gets or sets action needs to be taken on rule execution. + /// + [JsonProperty(PropertyName = "properties.action")] + public Action Action { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Source == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Source"); + } + if (Schedule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Schedule"); + } + if (Action == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Action"); + } + if (Source != null) + { + Source.Validate(); + } + if (Schedule != null) + { + Schedule.Validate(); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogSearchRuleResourcePatch.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogSearchRuleResourcePatch.cs new file mode 100644 index 000000000000..5b112d1f6893 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogSearchRuleResourcePatch.cs @@ -0,0 +1,68 @@ +// +// 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 log search rule resource for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class LogSearchRuleResourcePatch + { + /// + /// Initializes a new instance of the LogSearchRuleResourcePatch class. + /// + public LogSearchRuleResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogSearchRuleResourcePatch class. + /// + /// Resource tags + /// The flag which indicates whether the Log + /// Search rule is enabled. Value should be true or false. Possible + /// values include: 'true', 'false' + public LogSearchRuleResourcePatch(IDictionary tags = default(IDictionary), string enabled = default(string)) + { + Tags = tags; + Enabled = enabled; + 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 flag which indicates whether the Log Search rule + /// is enabled. Value should be true or false. Possible values include: + /// 'true', 'false' + /// + [JsonProperty(PropertyName = "properties.enabled")] + public string Enabled { get; set; } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogicAppReceiver.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogicAppReceiver.cs new file mode 100644 index 000000000000..0ee911383ac4 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/LogicAppReceiver.cs @@ -0,0 +1,93 @@ +// +// 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.Linq; + + /// + /// A logic app receiver. + /// + public partial class LogicAppReceiver + { + /// + /// Initializes a new instance of the LogicAppReceiver class. + /// + public LogicAppReceiver() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogicAppReceiver class. + /// + /// The name of the logic app receiver. Names must + /// be unique across all receivers within an action group. + /// The azure resource id of the logic app + /// receiver. + /// The callback url where http request sent + /// to. + public LogicAppReceiver(string name, string resourceId, string callbackUrl) + { + Name = name; + ResourceId = resourceId; + CallbackUrl = callbackUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the logic app receiver. Names must be + /// unique across all receivers within an action group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the azure resource id of the logic app receiver. + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; set; } + + /// + /// Gets or sets the callback url where http request sent to. + /// + [JsonProperty(PropertyName = "callbackUrl")] + public string CallbackUrl { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (ResourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceId"); + } + if (CallbackUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CallbackUrl"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs index 386f786f8a6c..8341e8e002b0 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertAction.cs @@ -33,6 +33,8 @@ public MetricAlertAction() /// /// the id of the action group to /// use. + /// The properties of a webhook + /// object. public MetricAlertAction(string actionGroupId = default(string), IDictionary webhookProperties = default(IDictionary)) { ActionGroupId = actionGroupId; @@ -52,6 +54,7 @@ public MetricAlertAction() public string ActionGroupId { get; set; } /// + /// Gets or sets the properties of a webhook object. /// [JsonProperty(PropertyName = "webhookProperties")] public IDictionary WebhookProperties { get; set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs index 8ae96d8cfc0e..ba3dedbad37d 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricAlertStatusProperties.cs @@ -33,6 +33,8 @@ public MetricAlertStatusProperties() /// Initializes a new instance of the MetricAlertStatusProperties /// class. /// + /// An object describing the type of the + /// dimensions. /// status value /// UTC time when the status was /// checked. @@ -50,6 +52,7 @@ public MetricAlertStatusProperties() partial void CustomInit(); /// + /// Gets or sets an object describing the type of the dimensions. /// [JsonProperty(PropertyName = "dimensions")] public IDictionary Dimensions { get; set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs index 53a98214ac8b..2cefd3859613 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricCriteria.cs @@ -16,6 +16,9 @@ namespace Microsoft.Azure.Management.Monitor.Models using System.Collections.Generic; using System.Linq; + /// + /// Criterion to filter metrics. + /// public partial class MetricCriteria { /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs index 45c140c83595..132e66c3e549 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricDimension.cs @@ -16,6 +16,9 @@ namespace Microsoft.Azure.Management.Monitor.Models using System.Collections.Generic; using System.Linq; + /// + /// Specifies a metric dimension. + /// public partial class MetricDimension { /// diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricTriggerType.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricTriggerType.cs new file mode 100644 index 000000000000..24af791a1b58 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/MetricTriggerType.cs @@ -0,0 +1,22 @@ +// +// 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 +{ + + /// + /// Defines values for MetricTriggerType. + /// + public static class MetricTriggerType + { + public const string Consecutive = "Consecutive"; + public const string Total = "Total"; + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/ProvisioningState.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..2ee59caf6da6 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/ProvisioningState.cs @@ -0,0 +1,24 @@ +// +// 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 +{ + + /// + /// Defines values for ProvisioningState. + /// + public static class ProvisioningState + { + public const string Succeeded = "Succeeded"; + public const string Deploying = "Deploying"; + public const string Canceled = "Canceled"; + public const string Failed = "Failed"; + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/QueryType.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/QueryType.cs new file mode 100644 index 000000000000..0902482ca98a --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/QueryType.cs @@ -0,0 +1,21 @@ +// +// 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 +{ + + /// + /// Defines values for QueryType. + /// + public static class QueryType + { + public const string ResultCount = "ResultCount"; + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Recurrence.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Recurrence.cs index a3b4d8341260..040810a5ece6 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Recurrence.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Recurrence.cs @@ -33,9 +33,11 @@ public Recurrence() /// /// the recurrence frequency. How often the /// schedule profile should take effect. This value must be Week, - /// meaning each week will have the same set of profiles. Possible - /// values include: 'None', 'Second', 'Minute', 'Hour', 'Day', 'Week', - /// 'Month', 'Year' + /// meaning each week will have the same set of profiles. For example, + /// to set a daily schedule, set **schedule** to every day of the week. + /// The frequency property specifies that the schedule is repeated + /// weekly. Possible values include: 'None', 'Second', 'Minute', + /// 'Hour', 'Day', 'Week', 'Month', 'Year' /// the scheduling constraints for when the /// profile begins. public Recurrence(RecurrenceFrequency frequency, RecurrentSchedule schedule) @@ -53,8 +55,11 @@ public Recurrence(RecurrenceFrequency frequency, RecurrentSchedule schedule) /// /// Gets or sets the recurrence frequency. How often the schedule /// profile should take effect. This value must be Week, meaning each - /// week will have the same set of profiles. Possible values include: - /// 'None', 'Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year' + /// week will have the same set of profiles. For example, to set a + /// daily schedule, set **schedule** to every day of the week. The + /// frequency property specifies that the schedule is repeated weekly. + /// Possible values include: 'None', 'Second', 'Minute', 'Hour', 'Day', + /// 'Week', 'Month', 'Year' /// [JsonProperty(PropertyName = "frequency")] public RecurrenceFrequency Frequency { get; set; } diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Schedule.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Schedule.cs new file mode 100644 index 000000000000..0afc58da2f73 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Schedule.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// 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; + + /// + /// Defines how often to run the search and the time interval. + /// + public partial class Schedule + { + /// + /// Initializes a new instance of the Schedule class. + /// + public Schedule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Schedule class. + /// + /// frequency (in minutes) at which + /// rule condition should be evaluated. + /// Time window for which data needs + /// to be fetched for query (should be greater than or equal to + /// frequencyInMinutes). + public Schedule(int frequencyInMinutes, int timeWindowInMinutes) + { + FrequencyInMinutes = frequencyInMinutes; + TimeWindowInMinutes = timeWindowInMinutes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets frequency (in minutes) at which rule condition should + /// be evaluated. + /// + [JsonProperty(PropertyName = "frequencyInMinutes")] + public int FrequencyInMinutes { get; set; } + + /// + /// Gets or sets time window for which data needs to be fetched for + /// query (should be greater than or equal to frequencyInMinutes). + /// + [JsonProperty(PropertyName = "timeWindowInMinutes")] + public int TimeWindowInMinutes { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/Source.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Source.cs new file mode 100644 index 000000000000..aaa75e925deb --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/Source.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the log search query. + /// + public partial class Source + { + /// + /// Initializes a new instance of the Source class. + /// + public Source() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Source class. + /// + /// Log search query. + /// The resource uri over which log search + /// query is to be run. + /// List of Resource referred into + /// query + /// Set value to 'ResultCount'. Possible values + /// include: 'ResultCount' + public Source(string query, string dataSourceId, IList authorizedResources = default(IList), string queryType = default(string)) + { + Query = query; + AuthorizedResources = authorizedResources; + DataSourceId = dataSourceId; + QueryType = queryType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets log search query. + /// + [JsonProperty(PropertyName = "query")] + public string Query { get; set; } + + /// + /// Gets or sets list of Resource referred into query + /// + [JsonProperty(PropertyName = "authorizedResources")] + public IList AuthorizedResources { get; set; } + + /// + /// Gets or sets the resource uri over which log search query is to be + /// run. + /// + [JsonProperty(PropertyName = "dataSourceId")] + public string DataSourceId { get; set; } + + /// + /// Gets or sets set value to 'ResultCount'. Possible values include: + /// 'ResultCount' + /// + [JsonProperty(PropertyName = "queryType")] + public string QueryType { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Query == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Query"); + } + if (DataSourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DataSourceId"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/TriggerCondition.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/TriggerCondition.cs new file mode 100644 index 000000000000..c14ebe65e730 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/TriggerCondition.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.Linq; + + /// + /// The condition that results in the Log Search rule. + /// + public partial class TriggerCondition + { + /// + /// Initializes a new instance of the TriggerCondition class. + /// + public TriggerCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TriggerCondition class. + /// + /// Evaluation operation for rule - + /// 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + /// 'LessThan', 'Equal' + /// Result or count threshold based on which + /// rule should be triggered. + /// Trigger condition for metric query + /// rule + public TriggerCondition(string thresholdOperator, double threshold, LogMetricTrigger metricTrigger = default(LogMetricTrigger)) + { + ThresholdOperator = thresholdOperator; + Threshold = threshold; + MetricTrigger = metricTrigger; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets evaluation operation for rule - 'GreaterThan' or + /// 'LessThan. Possible values include: 'GreaterThan', 'LessThan', + /// 'Equal' + /// + [JsonProperty(PropertyName = "thresholdOperator")] + public string ThresholdOperator { get; set; } + + /// + /// Gets or sets result or count threshold based on which rule should + /// be triggered. + /// + [JsonProperty(PropertyName = "threshold")] + public double Threshold { get; set; } + + /// + /// Gets or sets trigger condition for metric query rule + /// + [JsonProperty(PropertyName = "metricTrigger")] + public LogMetricTrigger MetricTrigger { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ThresholdOperator == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ThresholdOperator"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/Models/VoiceReceiver.cs b/src/SDKs/Monitor/Management.Monitor/Generated/Models/VoiceReceiver.cs new file mode 100644 index 000000000000..b2940329206c --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/Models/VoiceReceiver.cs @@ -0,0 +1,93 @@ +// +// 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.Linq; + + /// + /// A voice receiver. + /// + public partial class VoiceReceiver + { + /// + /// Initializes a new instance of the VoiceReceiver class. + /// + public VoiceReceiver() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VoiceReceiver class. + /// + /// The name of the voice receiver. Names must be + /// unique across all receivers within an action group. + /// The country code of the voice + /// receiver. + /// The phone number of the voice + /// receiver. + public VoiceReceiver(string name, string countryCode, string phoneNumber) + { + Name = name; + CountryCode = countryCode; + PhoneNumber = phoneNumber; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the voice receiver. Names must be unique + /// across all receivers within an action group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the country code of the voice receiver. + /// + [JsonProperty(PropertyName = "countryCode")] + public string CountryCode { get; set; } + + /// + /// Gets or sets the phone number of the voice receiver. + /// + [JsonProperty(PropertyName = "phoneNumber")] + public string PhoneNumber { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (CountryCode == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CountryCode"); + } + if (PhoneNumber == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PhoneNumber"); + } + } + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs index e7e42efa8f22..e7c18ac8e09b 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/MonitorManagementClient.cs @@ -52,19 +52,20 @@ public partial class MonitorManagementClient : ServiceClient - /// Gets or sets the preferred language for the response. + /// The preferred language for the response. /// public string AcceptLanguage { get; set; } /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. /// public int? LongRunningOperationRetryTimeout { get; set; } /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. /// public bool? GenerateClientRequestId { get; set; } @@ -153,6 +154,24 @@ public partial class MonitorManagementClient : ServiceClient public virtual IMetricAlertsStatusOperations MetricAlertsStatus { get; private set; } + /// + /// Gets the IScheduledQueryRulesOperations. + /// + public virtual IScheduledQueryRulesOperations ScheduledQueryRules { get; private set; } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MonitorManagementClient.Dispose(). False: will not dispose provided httpClient + protected MonitorManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + /// /// Initializes a new instance of the MonitorManagementClient class. /// @@ -248,6 +267,33 @@ public MonitorManagementClient(ServiceClientCredentials credentials, params Dele } } + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MonitorManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public MonitorManagementClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + /// /// Initializes a new instance of the MonitorManagementClient class. /// @@ -371,6 +417,7 @@ private void Initialize() MetricBaseline = new MetricBaselineOperations(this); MetricAlerts = new MetricAlertsOperations(this); MetricAlertsStatus = new MetricAlertsStatusOperations(this); + ScheduledQueryRules = new ScheduledQueryRulesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; @@ -407,10 +454,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")); + 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/ScheduledQueryRulesOperations.cs b/src/SDKs/Monitor/Management.Monitor/Generated/ScheduledQueryRulesOperations.cs new file mode 100644 index 000000000000..7f8e04788001 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/ScheduledQueryRulesOperations.cs @@ -0,0 +1,1215 @@ +// +// 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 Microsoft.Rest.Azure.OData; + 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; + + /// + /// ScheduledQueryRulesOperations operations. + /// + internal partial class ScheduledQueryRulesOperations : IServiceOperations, IScheduledQueryRulesOperations + { + /// + /// Initializes a new instance of the ScheduledQueryRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ScheduledQueryRulesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Creates or updates an log search rule. + /// + /// + /// 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, LogSearchRuleResource 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-04-16"; + // 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/scheduledQueryRules/{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 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an Log Search rule + /// + /// + /// 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 (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2018-04-16"; + // 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/scheduledQueryRules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _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; + } + + /// + /// Update log search Rule. + /// + /// + /// 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, LogSearchRuleResourcePatch 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-04-16"; + // 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/scheduledQueryRules/{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; + } + + /// + /// Deletes a Log Search rule + /// + /// + /// 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 (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2018-04-16"; + // 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/scheduledQueryRules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the Log Search rules within a subscription group. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2018-04-16"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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/scheduledQueryRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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; + } + + /// + /// List the Log Search rules within a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2018-04-16"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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/scheduledQueryRules").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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/ScheduledQueryRulesOperationsExtensions.cs b/src/SDKs/Monitor/Management.Monitor/Generated/ScheduledQueryRulesOperationsExtensions.cs new file mode 100644 index 000000000000..d654ec4b1956 --- /dev/null +++ b/src/SDKs/Monitor/Management.Monitor/Generated/ScheduledQueryRulesOperationsExtensions.cs @@ -0,0 +1,271 @@ +// +// 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 Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ScheduledQueryRulesOperations. + /// + public static partial class ScheduledQueryRulesOperationsExtensions + { + /// + /// Creates or updates an log search rule. + /// + /// + /// 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 LogSearchRuleResource CreateOrUpdate(this IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName, LogSearchRuleResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an log search rule. + /// + /// + /// 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 IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName, LogSearchRuleResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an Log Search rule + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + public static LogSearchRuleResource Get(this IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName) + { + return operations.GetAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Gets an Log Search rule + /// + /// + /// 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 IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update log search Rule. + /// + /// + /// 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 LogSearchRuleResource Update(this IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters) + { + return operations.UpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Update log search Rule. + /// + /// + /// 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 IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName, LogSearchRuleResourcePatch parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a Log Search rule + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the rule. + /// + public static void Delete(this IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a Log Search rule + /// + /// + /// 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 IScheduledQueryRulesOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List the Log Search rules within a subscription group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IEnumerable ListBySubscription(this IScheduledQueryRulesOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListBySubscriptionAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List the Log Search rules within a subscription group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IScheduledQueryRulesOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the Log Search rules within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IEnumerable ListByResourceGroup(this IScheduledQueryRulesOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List the Log Search rules within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IScheduledQueryRulesOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs b/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs index 705caf831a40..b87bc48b2278 100644 --- a/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs +++ b/src/SDKs/Monitor/Management.Monitor/Generated/SdkInfo_MonitorClient.cs @@ -21,7 +21,7 @@ public static IEnumerable> ApiInfo_MonitorClient { new Tuple("Insights", "MetricAlerts", "2018-03-01"), new Tuple("Insights", "MetricAlertsStatus", "2018-03-01"), - new Tuple("insights", "ActionGroups", "2017-04-01"), + new Tuple("insights", "ActionGroups", "2018-03-01"), new Tuple("insights", "ActivityLogAlerts", "2017-04-01"), new Tuple("insights", "ActivityLogs", "2015-04-01"), new Tuple("insights", "AlertRuleIncidents", "2016-03-01"), @@ -35,6 +35,7 @@ public static IEnumerable> ApiInfo_MonitorClient new Tuple("insights", "MetricDefinitions", "2018-01-01"), new Tuple("insights", "Metrics", "2018-01-01"), new Tuple("insights", "Operations", "2015-04-01"), + new Tuple("insights", "ScheduledQueryRules", "2018-04-16"), new Tuple("insights", "TenantActivityLogs", "2015-04-01"), }.AsEnumerable(); } diff --git a/src/SDKs/_metadata/monitor_resource-manager.txt b/src/SDKs/_metadata/monitor_resource-manager.txt index 7b3044a3970e..178b695734b2 100644 --- a/src/SDKs/_metadata/monitor_resource-manager.txt +++ b/src/SDKs/_metadata/monitor_resource-manager.txt @@ -1,33 +1,18 @@ Installing AutoRest version: latest - -> autorest@2.0.4262 preinstall C:\Users\sanjaych\AppData\Roaming\npm\node_modules\autorest -> node ./preinstall-check - -C:\Users\sanjaych\AppData\Roaming\npm\autorest -> C:\Users\sanjaych\AppData\Roaming\npm\node_modules\autorest\dist\app.js -+ autorest@2.0.4262 -updated 1 package in 2.263s - AutoRest installed successfully. Commencing code generation Generating CSharp code Executing AutoRest command -cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=D:\AzureSDK\azure-sdk-for-net\src\SDKs -AutoRest code generation utility [version: 2.0.4262; node: v8.11.1] -(C) 2018 Microsoft Corporation. -https://aka.ms/autorest - Loading AutoRest core 'C:\Users\sanjaych\.autorest\@microsoft.azure_autorest-core@2.0.4279\node_modules\@microsoft.azure\autorest-core\dist' (2.0.4279) - Loading AutoRest extension '@microsoft.azure/autorest.csharp' (~2.2.51->2.2.57) - Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.43->2.3.43) - -2018-06-08 04:20:38 UTC +cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=D:\myFork\psSdkJson6\src\SDKs +2018-08-07 18:58:07 UTC 1) azure-rest-api-specs repository information GitHub fork: Azure Branch: master -Commit: e02b7682d09d6600aca3a52744413af1c5e15787 +Commit: 9319b76cd4027151e6d3b0de3b0e8472f7e5169f 2) AutoRest information Requested version: latest -Bootstrapper version: C:\Users\sanjaych\AppData\Roaming\npm `-- autorest@2.0.4262 +Bootstrapper version: autorest@2.0.4283 Latest installed version: