From 3fb6f50bb360978c0f3c7686458951257f0dff7e Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Mon, 20 Apr 2020 03:38:32 +0000 Subject: [PATCH] Generated from 09e12cd47ec6529bf29f9cd251d9699187c01964 update test --- .../src/Generated/ActionRulesOperations.cs | 78 +- .../src/Generated/AlertsManagementClient.cs | 17 +- .../src/Generated/AlertsOperations.cs | 236 ++- .../Generated/AlertsOperationsExtensions.cs | 28 + .../src/Generated/IAlertsManagementClient.cs | 13 +- .../src/Generated/IAlertsOperations.cs | 20 + .../ISmartDetectorAlertRulesOperations.cs | 228 +++ .../src/Generated/Models/ActionGroup.cs | 1 + .../Models/ActionGroupsInformation.cs | 87 + .../Generated/Models/ActionRuleProperties.cs | 1 + .../src/Generated/Models/AlertRule.cs | 163 ++ .../Generated/Models/AlertRulePatchObject.cs | 147 ++ .../src/Generated/Models/AlertRuleState.cs | 22 + .../src/Generated/Models/AlertsMetaData.cs | 49 + .../Models/AlertsMetaDataProperties.cs | 37 + .../src/Generated/Models/AzureResource.cs | 85 + .../src/Generated/Models/Detector.cs | 120 ++ .../src/Generated/Models/Diagnostics.cs | 2 + .../src/Generated/Models/ErrorResponse1.cs | 60 + .../Models/ErrorResponse1Exception.cs | 62 + .../Generated/Models/MonitorServiceDetails.cs | 59 + .../Generated/Models/MonitorServiceList.cs | 71 + .../src/Generated/Models/Suppression.cs | 1 + .../Generated/Models/ThrottlingInformation.cs | 55 + .../src/Generated/Operations.cs | 6 +- .../SdkInfo_AlertsManagementClient.cs | 31 + .../SmartDetectorAlertRulesOperations.cs | 1594 +++++++++++++++++ ...tDetectorAlertRulesOperationsExtensions.cs | 346 ++++ .../src/Generated/SmartGroupsOperations.cs | 52 +- 29 files changed, 3628 insertions(+), 43 deletions(-) create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ISmartDetectorAlertRulesOperations.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroupsInformation.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRule.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRulePatchObject.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRuleState.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaData.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaDataProperties.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AzureResource.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Detector.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1Exception.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceDetails.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceList.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ThrottlingInformation.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SdkInfo_AlertsManagementClient.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperations.cs create mode 100644 sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperationsExtensions.cs diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ActionRulesOperations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ActionRulesOperations.cs index bbe0ca33f084..fa1277753ce0 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ActionRulesOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ActionRulesOperations.cs @@ -121,6 +121,14 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -138,6 +146,7 @@ internal ActionRulesOperations(AlertsManagementClient client) tracingParameters.Add("alertRuleId", alertRuleId); tracingParameters.Add("actionGroup", actionGroup); tracingParameters.Add("name", name); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); } @@ -186,9 +195,9 @@ internal ActionRulesOperations(AlertsManagementClient client) { _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -398,10 +407,18 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -420,6 +437,7 @@ internal ActionRulesOperations(AlertsManagementClient client) tracingParameters.Add("alertRuleId", alertRuleId); tracingParameters.Add("actionGroup", actionGroup); tracingParameters.Add("name", name); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); } @@ -469,9 +487,9 @@ internal ActionRulesOperations(AlertsManagementClient client) { _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -645,6 +663,13 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); @@ -653,6 +678,7 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "actionRuleName"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -662,6 +688,7 @@ internal ActionRulesOperations(AlertsManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("actionRuleName", actionRuleName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetByName", tracingParameters); } @@ -672,9 +699,9 @@ internal ActionRulesOperations(AlertsManagementClient client) _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{actionRuleName}", System.Uri.EscapeDataString(actionRuleName)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -851,6 +878,13 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); @@ -867,6 +901,7 @@ internal ActionRulesOperations(AlertsManagementClient client) { actionRule.Validate(); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -877,6 +912,7 @@ internal ActionRulesOperations(AlertsManagementClient client) tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("actionRuleName", actionRuleName); tracingParameters.Add("actionRule", actionRule); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "CreateUpdate", tracingParameters); } @@ -887,9 +923,9 @@ internal ActionRulesOperations(AlertsManagementClient client) _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{actionRuleName}", System.Uri.EscapeDataString(actionRuleName)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1069,6 +1105,13 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); @@ -1077,6 +1120,7 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "actionRuleName"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1086,6 +1130,7 @@ internal ActionRulesOperations(AlertsManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("actionRuleName", actionRuleName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); } @@ -1096,9 +1141,9 @@ internal ActionRulesOperations(AlertsManagementClient client) _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{actionRuleName}", System.Uri.EscapeDataString(actionRuleName)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1275,6 +1320,13 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); @@ -1287,6 +1339,7 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "actionRulePatch"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1297,6 +1350,7 @@ internal ActionRulesOperations(AlertsManagementClient client) tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("actionRuleName", actionRuleName); tracingParameters.Add("actionRulePatch", actionRulePatch); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); } @@ -1307,9 +1361,9 @@ internal ActionRulesOperations(AlertsManagementClient client) _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{actionRuleName}", System.Uri.EscapeDataString(actionRuleName)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsManagementClient.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsManagementClient.cs index de985046e81b..a7391ed991a7 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsManagementClient.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsManagementClient.cs @@ -47,16 +47,14 @@ public partial class AlertsManagementClient : ServiceClient - /// Subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every service - /// call. + /// The ID of the target subscription. /// public string SubscriptionId { get; set; } /// - /// client API version + /// The ID of the target subscription. /// - public string ApiVersion { get; private set; } + public string SubscriptionId1 { get; set; } /// /// The preferred language for the response. @@ -96,6 +94,11 @@ public partial class AlertsManagementClient : ServiceClient public virtual IActionRulesOperations ActionRules { get; private set; } + /// + /// Gets the ISmartDetectorAlertRulesOperations. + /// + public virtual ISmartDetectorAlertRulesOperations SmartDetectorAlertRules { get; private set; } + /// /// Initializes a new instance of the AlertsManagementClient class. /// @@ -341,8 +344,8 @@ private void Initialize() Alerts = new AlertsOperations(this); SmartGroups = new SmartGroupsOperations(this); ActionRules = new ActionRulesOperations(this); + SmartDetectorAlertRules = new SmartDetectorAlertRulesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2019-05-05-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; @@ -374,6 +377,8 @@ private void Initialize() }; SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("type")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("metadataIdentifier")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("metadataIdentifier")); CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperations.cs index 30871a356e40..7c6a16bd894d 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperations.cs @@ -50,6 +50,177 @@ internal AlertsOperations(AlertsManagementClient client) /// public AlertsManagementClient Client { get; private set; } + /// + /// List alerts meta data information based on value of identifier parameter. + /// + /// + /// 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 + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> MetaDataWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + string apiVersion = "2019-05-05-preview"; + string identifier = "MonitorServiceList"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("identifier", identifier); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "MetaData", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.AlertsManagement/alertsMetaData").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (identifier != null) + { + _queryParameters.Add(string.Format("identifier={0}", System.Uri.EscapeDataString(identifier))); + } + 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; + } + /// /// List all existing alerts, where the results can be filtered on the basis of /// multiple parameters (e.g. time range). The results can then be sorted on @@ -159,6 +330,14 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -183,6 +362,7 @@ internal AlertsOperations(AlertsManagementClient client) tracingParameters.Add("select", select); tracingParameters.Add("timeRange", timeRange); tracingParameters.Add("customTimeRange", customTimeRange); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetAll", tracingParameters); } @@ -259,9 +439,9 @@ internal AlertsOperations(AlertsManagementClient client) { _queryParameters.Add(string.Format("customTimeRange={0}", System.Uri.EscapeDataString(customTimeRange))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -419,10 +599,18 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (alertId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -431,6 +619,7 @@ internal AlertsOperations(AlertsManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("alertId", alertId); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetById", tracingParameters); } @@ -440,9 +629,9 @@ internal AlertsOperations(AlertsManagementClient client) _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{alertId}", System.Uri.EscapeDataString(alertId)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -601,6 +790,13 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (alertId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); @@ -609,6 +805,7 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "newState"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -617,6 +814,7 @@ internal AlertsOperations(AlertsManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("alertId", alertId); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("newState", newState); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ChangeState", tracingParameters); @@ -627,9 +825,9 @@ internal AlertsOperations(AlertsManagementClient client) _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{alertId}", System.Uri.EscapeDataString(alertId)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (newState != null) { @@ -789,10 +987,18 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (alertId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -801,6 +1007,7 @@ internal AlertsOperations(AlertsManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("alertId", alertId); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetHistory", tracingParameters); } @@ -810,9 +1017,9 @@ internal AlertsOperations(AlertsManagementClient client) _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{alertId}", System.Uri.EscapeDataString(alertId)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1019,10 +1226,18 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (groupby == null) { throw new ValidationException(ValidationRules.CannotBeNull, "groupby"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1042,6 +1257,7 @@ internal AlertsOperations(AlertsManagementClient client) tracingParameters.Add("alertRule", alertRule); tracingParameters.Add("timeRange", timeRange); tracingParameters.Add("customTimeRange", customTimeRange); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetSummary", tracingParameters); } @@ -1098,9 +1314,9 @@ internal AlertsOperations(AlertsManagementClient client) { _queryParameters.Add(string.Format("customTimeRange={0}", System.Uri.EscapeDataString(customTimeRange))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperationsExtensions.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperationsExtensions.cs index 3ff4383f0c49..e1f6ec2ea219 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperationsExtensions.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperationsExtensions.cs @@ -21,6 +21,34 @@ namespace Microsoft.Azure.Management.AlertsManagement /// public static partial class AlertsOperationsExtensions { + /// + /// List alerts meta data information based on value of identifier parameter. + /// + /// + /// The operations group for this extension method. + /// + public static AlertsMetaData MetaData(this IAlertsOperations operations) + { + return operations.MetaDataAsync().GetAwaiter().GetResult(); + } + + /// + /// List alerts meta data information based on value of identifier parameter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task MetaDataAsync(this IAlertsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.MetaDataWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// List all existing alerts, where the results can be filtered on the basis of /// multiple parameters (e.g. time range). The results can then be sorted on diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs index f31c1263bdf9..e5cc7a9914a3 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs @@ -41,16 +41,14 @@ public partial interface IAlertsManagementClient : System.IDisposable ServiceClientCredentials Credentials { get; } /// - /// Subscription credentials which uniquely identify Microsoft Azure - /// subscription. The subscription ID forms part of the URI for every - /// service call. + /// The ID of the target subscription. /// string SubscriptionId { get; set; } /// - /// client API version + /// The ID of the target subscription. /// - string ApiVersion { get; } + string SubscriptionId1 { get; set; } /// /// The preferred language for the response. @@ -91,5 +89,10 @@ public partial interface IAlertsManagementClient : System.IDisposable /// IActionRulesOperations ActionRules { get; } + /// + /// Gets the ISmartDetectorAlertRulesOperations. + /// + ISmartDetectorAlertRulesOperations SmartDetectorAlertRules { get; } + } } diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsOperations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsOperations.cs index fac19dc86374..32a11491ad02 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsOperations.cs @@ -23,6 +23,26 @@ namespace Microsoft.Azure.Management.AlertsManagement /// public partial interface IAlertsOperations { + /// + /// List alerts meta data information based on value of identifier + /// parameter. + /// + /// + /// 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> MetaDataWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// List all existing alerts, where the results can be filtered on the /// basis of multiple parameters (e.g. time range). The results can diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ISmartDetectorAlertRulesOperations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ISmartDetectorAlertRulesOperations.cs new file mode 100644 index 000000000000..e393c31d4dd0 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ISmartDetectorAlertRulesOperations.cs @@ -0,0 +1,228 @@ +// +// 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.AlertsManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SmartDetectorAlertRulesOperations operations. + /// + public partial interface ISmartDetectorAlertRulesOperations + { + /// + /// List all the existing Smart Detector alert rules within the + /// subscription. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(bool? expandDetector = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the existing Smart Detector alert rules within the + /// subscription and resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// 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, bool? expandDetector = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a specific Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// 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 alertRuleName, bool? expandDetector = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string alertRuleName, AlertRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Patch a specific Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> PatchWithHttpMessagesAsync(string resourceGroupName, string alertRuleName, AlertRulePatchObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an existing Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert 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 alertRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the existing Smart Detector alert rules within the + /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the existing Smart Detector alert rules within the + /// subscription and resource group. + /// + /// + /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroup.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroup.cs index 57f9b62a8dc0..e439c1005ebc 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroup.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroup.cs @@ -20,6 +20,7 @@ namespace Microsoft.Azure.Management.AlertsManagement.Models /// /// Action rule with action group configuration /// + [Newtonsoft.Json.JsonObject("ActionGroup")] public partial class ActionGroup : ActionRuleProperties { /// diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroupsInformation.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroupsInformation.cs new file mode 100644 index 000000000000..f70748c97f1a --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroupsInformation.cs @@ -0,0 +1,87 @@ +// +// 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.AlertsManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The Action Groups information, used by the alert rule. + /// + public partial class ActionGroupsInformation + { + /// + /// Initializes a new instance of the ActionGroupsInformation class. + /// + public ActionGroupsInformation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ActionGroupsInformation class. + /// + /// The Action Group resource IDs. + /// An optional custom email subject + /// to use in email notifications. + /// An optional custom web-hook + /// payload to use in web-hook notifications. + public ActionGroupsInformation(IList groupIds, string customEmailSubject = default(string), string customWebhookPayload = default(string)) + { + CustomEmailSubject = customEmailSubject; + CustomWebhookPayload = customWebhookPayload; + GroupIds = groupIds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an optional custom email subject to use in email + /// notifications. + /// + [JsonProperty(PropertyName = "customEmailSubject")] + public string CustomEmailSubject { get; set; } + + /// + /// Gets or sets an optional custom web-hook payload to use in web-hook + /// notifications. + /// + [JsonProperty(PropertyName = "customWebhookPayload")] + public string CustomWebhookPayload { get; set; } + + /// + /// Gets or sets the Action Group resource IDs. + /// + [JsonProperty(PropertyName = "groupIds")] + public IList GroupIds { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (GroupIds == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "GroupIds"); + } + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionRuleProperties.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionRuleProperties.cs index 4fd27d6a40c6..9d3766e0cb88 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionRuleProperties.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionRuleProperties.cs @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Management.AlertsManagement.Models /// Action rule properties defining scope, conditions, suppression logic /// for action rule /// + [Newtonsoft.Json.JsonObject("ActionRuleProperties")] public partial class ActionRuleProperties { /// diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRule.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRule.cs new file mode 100644 index 000000000000..dfa4dcbe0252 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRule.cs @@ -0,0 +1,163 @@ +// +// 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.AlertsManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The alert rule information + /// + [Rest.Serialization.JsonTransformation] + public partial class AlertRule : AzureResource + { + /// + /// Initializes a new instance of the AlertRule class. + /// + public AlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertRule class. + /// + /// The alert rule state. Possible values include: + /// 'Enabled', 'Disabled' + /// The alert rule severity. Possible values + /// include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + /// The alert rule frequency in ISO8601 format. + /// The time granularity must be in minutes and minimum value is 5 + /// minutes. + /// The alert rule's detector. + /// The alert rule resources scope. + /// The alert rule actions. + /// The resource ID. + /// The resource type. + /// The resource name. + /// The resource location. + /// The resource tags. + /// The alert rule description. + /// The alert rule throttling + /// information. + public AlertRule(string state, string severity, System.TimeSpan frequency, Detector detector, IList scope, ActionGroupsInformation actionGroups, string id = default(string), string type = default(string), string name = default(string), string location = default(string), object tags = default(object), string description = default(string), ThrottlingInformation throttling = default(ThrottlingInformation)) + : base(id, type, name, location, tags) + { + Description = description; + State = state; + Severity = severity; + Frequency = frequency; + Detector = detector; + Scope = scope; + ActionGroups = actionGroups; + Throttling = throttling; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the alert rule description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the alert rule state. Possible values include: + /// 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; set; } + + /// + /// Gets or sets the alert rule severity. Possible values include: + /// 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + /// + [JsonProperty(PropertyName = "properties.severity")] + public string Severity { get; set; } + + /// + /// Gets or sets the alert rule frequency in ISO8601 format. The time + /// granularity must be in minutes and minimum value is 5 minutes. + /// + [JsonProperty(PropertyName = "properties.frequency")] + public System.TimeSpan Frequency { get; set; } + + /// + /// Gets or sets the alert rule's detector. + /// + [JsonProperty(PropertyName = "properties.detector")] + public Detector Detector { get; set; } + + /// + /// Gets or sets the alert rule resources scope. + /// + [JsonProperty(PropertyName = "properties.scope")] + public IList Scope { get; set; } + + /// + /// Gets or sets the alert rule actions. + /// + [JsonProperty(PropertyName = "properties.actionGroups")] + public ActionGroupsInformation ActionGroups { get; set; } + + /// + /// Gets or sets the alert rule throttling information. + /// + [JsonProperty(PropertyName = "properties.throttling")] + public ThrottlingInformation Throttling { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (State == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "State"); + } + if (Severity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Severity"); + } + if (Detector == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Detector"); + } + if (Scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Scope"); + } + if (ActionGroups == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ActionGroups"); + } + if (Detector != null) + { + Detector.Validate(); + } + if (ActionGroups != null) + { + ActionGroups.Validate(); + } + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRulePatchObject.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRulePatchObject.cs new file mode 100644 index 000000000000..c490899c38b7 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRulePatchObject.cs @@ -0,0 +1,147 @@ +// +// 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.AlertsManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The alert rule patch information + /// + [Rest.Serialization.JsonTransformation] + public partial class AlertRulePatchObject + { + /// + /// Initializes a new instance of the AlertRulePatchObject class. + /// + public AlertRulePatchObject() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertRulePatchObject class. + /// + /// The resource ID. + /// The resource type. + /// The resource name. + /// The resource tags. + /// The alert rule description. + /// The alert rule state. Possible values include: + /// 'Enabled', 'Disabled' + /// The alert rule severity. Possible values + /// include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + /// The alert rule frequency in ISO8601 format. + /// The time granularity must be in minutes and minimum value is 5 + /// minutes. + /// The alert rule actions. + /// The alert rule throttling + /// information. + public AlertRulePatchObject(string id = default(string), string type = default(string), string name = default(string), object tags = default(object), string description = default(string), string state = default(string), string severity = default(string), System.TimeSpan? frequency = default(System.TimeSpan?), ActionGroupsInformation actionGroups = default(ActionGroupsInformation), ThrottlingInformation throttling = default(ThrottlingInformation)) + { + Id = id; + Type = type; + Name = name; + Tags = tags; + Description = description; + State = state; + Severity = severity; + Frequency = frequency; + ActionGroups = actionGroups; + Throttling = throttling; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public object Tags { get; set; } + + /// + /// Gets or sets the alert rule description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the alert rule state. Possible values include: + /// 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; set; } + + /// + /// Gets or sets the alert rule severity. Possible values include: + /// 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + /// + [JsonProperty(PropertyName = "properties.severity")] + public string Severity { get; set; } + + /// + /// Gets or sets the alert rule frequency in ISO8601 format. The time + /// granularity must be in minutes and minimum value is 5 minutes. + /// + [JsonProperty(PropertyName = "properties.frequency")] + public System.TimeSpan? Frequency { get; set; } + + /// + /// Gets or sets the alert rule actions. + /// + [JsonProperty(PropertyName = "properties.actionGroups")] + public ActionGroupsInformation ActionGroups { get; set; } + + /// + /// Gets or sets the alert rule throttling information. + /// + [JsonProperty(PropertyName = "properties.throttling")] + public ThrottlingInformation Throttling { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ActionGroups != null) + { + ActionGroups.Validate(); + } + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRuleState.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRuleState.cs new file mode 100644 index 000000000000..921f7d5ba692 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRuleState.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.AlertsManagement.Models +{ + + /// + /// Defines values for AlertRuleState. + /// + public static class AlertRuleState + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaData.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaData.cs new file mode 100644 index 000000000000..bf2f9335450a --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaData.cs @@ -0,0 +1,49 @@ +// +// 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.AlertsManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// alert meta data information. + /// + public partial class AlertsMetaData + { + /// + /// Initializes a new instance of the AlertsMetaData class. + /// + public AlertsMetaData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertsMetaData class. + /// + public AlertsMetaData(AlertsMetaDataProperties properties = default(AlertsMetaDataProperties)) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public AlertsMetaDataProperties Properties { get; set; } + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaDataProperties.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaDataProperties.cs new file mode 100644 index 000000000000..18cf9c088257 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertsMetaDataProperties.cs @@ -0,0 +1,37 @@ +// +// 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.AlertsManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// alert meta data property bag + /// + [Newtonsoft.Json.JsonObject("alertsMetaDataProperties")] + public partial class AlertsMetaDataProperties + { + /// + /// Initializes a new instance of the AlertsMetaDataProperties class. + /// + public AlertsMetaDataProperties() + { + CustomInit(); + } + + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AzureResource.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AzureResource.cs new file mode 100644 index 000000000000..c93f00c259b9 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AzureResource.cs @@ -0,0 +1,85 @@ +// +// 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.AlertsManagement.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An Azure resource object + /// + public partial class AzureResource : IResource + { + /// + /// Initializes a new instance of the AzureResource class. + /// + public AzureResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureResource class. + /// + /// The resource ID. + /// The resource type. + /// The resource name. + /// The resource location. + /// The resource tags. + public AzureResource(string id = default(string), string type = default(string), string name = default(string), string location = default(string), object tags = default(object)) + { + Id = id; + Type = type; + Name = name; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the resource location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public object Tags { get; set; } + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Detector.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Detector.cs new file mode 100644 index 000000000000..25b2286e9233 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Detector.cs @@ -0,0 +1,120 @@ +// +// 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.AlertsManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The detector information. By default this is not populated, unless it's + /// specified in expandDetector + /// + public partial class Detector + { + /// + /// Initializes a new instance of the Detector class. + /// + public Detector() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Detector class. + /// + /// The detector id. + /// The detector's parameters.' + /// The Smart Detector name. By default this is not + /// populated, unless it's specified in expandDetector + /// The Smart Detector description. By + /// default this is not populated, unless it's specified in + /// expandDetector + /// The Smart Detector supported + /// resource types. By default this is not populated, unless it's + /// specified in expandDetector + /// The Smart Detector image path. By default + /// this is not populated, unless it's specified in + /// expandDetector + public Detector(string id, IDictionary parameters = default(IDictionary), string name = default(string), string description = default(string), IList supportedResourceTypes = default(IList), IList imagePaths = default(IList)) + { + Id = id; + Parameters = parameters; + Name = name; + Description = description; + SupportedResourceTypes = supportedResourceTypes; + ImagePaths = imagePaths; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the detector id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the detector's parameters.' + /// + [JsonProperty(PropertyName = "parameters")] + public IDictionary Parameters { get; set; } + + /// + /// Gets or sets the Smart Detector name. By default this is not + /// populated, unless it's specified in expandDetector + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the Smart Detector description. By default this is not + /// populated, unless it's specified in expandDetector + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets the Smart Detector supported resource types. By + /// default this is not populated, unless it's specified in + /// expandDetector + /// + [JsonProperty(PropertyName = "supportedResourceTypes")] + public IList SupportedResourceTypes { get; set; } + + /// + /// Gets or sets the Smart Detector image path. By default this is not + /// populated, unless it's specified in expandDetector + /// + [JsonProperty(PropertyName = "imagePaths")] + public IList ImagePaths { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Diagnostics.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Diagnostics.cs index ccd078742e52..f0c7fd90bac1 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Diagnostics.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Diagnostics.cs @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Management.AlertsManagement.Models { + using Newtonsoft.Json; using System.Linq; /// @@ -18,6 +19,7 @@ namespace Microsoft.Azure.Management.AlertsManagement.Models /// /// Action rule with diagnostics configuration /// + [Newtonsoft.Json.JsonObject("Diagnostics")] public partial class Diagnostics : ActionRuleProperties { /// diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1.cs new file mode 100644 index 000000000000..4ece8dab85a8 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.AlertsManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describe the format of an Error response. + /// + public partial class ErrorResponse1 + { + /// + /// Initializes a new instance of the ErrorResponse1 class. + /// + public ErrorResponse1() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse1 class. + /// + /// Error code + /// Error message indicating why the operation + /// failed. + public ErrorResponse1(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message indicating why the operation failed. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1Exception.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1Exception.cs new file mode 100644 index 000000000000..8f3fa41be1c1 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ErrorResponse1Exception.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.AlertsManagement.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse1 + /// information. + /// + public partial class ErrorResponse1Exception : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse1 Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponse1Exception class. + /// + public ErrorResponse1Exception() + { + } + + /// + /// Initializes a new instance of the ErrorResponse1Exception class. + /// + /// The exception message. + public ErrorResponse1Exception(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponse1Exception class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponse1Exception(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceDetails.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceDetails.cs new file mode 100644 index 000000000000..3197effd1f1a --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceDetails.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.AlertsManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of a monitor service + /// + public partial class MonitorServiceDetails + { + /// + /// Initializes a new instance of the MonitorServiceDetails class. + /// + public MonitorServiceDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitorServiceDetails class. + /// + /// Monitor service name + /// Monitor service display name + public MonitorServiceDetails(string name = default(string), string displayName = default(string)) + { + Name = name; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets monitor service name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets monitor service display name + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceList.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceList.cs new file mode 100644 index 000000000000..c2e785c5bc72 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/MonitorServiceList.cs @@ -0,0 +1,71 @@ +// +// 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.AlertsManagement.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Monitor service details + /// + /// + /// Monitor service details + /// + [Newtonsoft.Json.JsonObject("MonitorServiceList")] + public partial class MonitorServiceList : AlertsMetaDataProperties + { + /// + /// Initializes a new instance of the MonitorServiceList class. + /// + public MonitorServiceList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitorServiceList class. + /// + /// Array of operations + public MonitorServiceList(IList data) + { + Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of operations + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Data == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Data"); + } + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Suppression.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Suppression.cs index ffe778345baa..7b0e99e730b5 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Suppression.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/Suppression.cs @@ -20,6 +20,7 @@ namespace Microsoft.Azure.Management.AlertsManagement.Models /// /// Action rule with suppression configuration /// + [Newtonsoft.Json.JsonObject("Suppression")] public partial class Suppression : ActionRuleProperties { /// diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ThrottlingInformation.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ThrottlingInformation.cs new file mode 100644 index 000000000000..d95264642502 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ThrottlingInformation.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.AlertsManagement.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Optional throttling information for the alert rule. + /// + public partial class ThrottlingInformation + { + /// + /// Initializes a new instance of the ThrottlingInformation class. + /// + public ThrottlingInformation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ThrottlingInformation class. + /// + /// The required duration (in ISO8601 format) to + /// wait before notifying on the alert rule again. The time granularity + /// must be in minutes and minimum value is 0 minutes + public ThrottlingInformation(System.TimeSpan? duration = default(System.TimeSpan?)) + { + Duration = duration; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the required duration (in ISO8601 format) to wait + /// before notifying on the alert rule again. The time granularity must + /// be in minutes and minimum value is 0 minutes + /// + [JsonProperty(PropertyName = "duration")] + public System.TimeSpan? Duration { get; set; } + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Operations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Operations.cs index 16c37fe1dac6..6f06eeda4bdf 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Operations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Operations.cs @@ -71,6 +71,7 @@ internal Operations(AlertsManagementClient client) /// public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -78,6 +79,7 @@ internal Operations(AlertsManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } @@ -85,9 +87,9 @@ internal Operations(AlertsManagementClient client) var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.AlertsManagement/operations").ToString(); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SdkInfo_AlertsManagementClient.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SdkInfo_AlertsManagementClient.cs new file mode 100644 index 000000000000..e678aff7fe2d --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SdkInfo_AlertsManagementClient.cs @@ -0,0 +1,31 @@ + +// +// 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.AlertsManagement +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_AlertsManagementClient + { + get + { + return new Tuple[] + { + new Tuple("AlertsManagement", "ActionRules", "2019-05-05-preview"), + new Tuple("AlertsManagement", "Alerts", "2019-05-05-preview"), + new Tuple("AlertsManagement", "Operations", "2019-05-05-preview"), + new Tuple("AlertsManagement", "SmartGroups", "2019-05-05-preview"), + new Tuple("alertsManagement", "SmartDetectorAlertRules", "2019-06-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperations.cs new file mode 100644 index 000000000000..2d8b8be5d64b --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperations.cs @@ -0,0 +1,1594 @@ +// +// 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.AlertsManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SmartDetectorAlertRulesOperations operations. + /// + internal partial class SmartDetectorAlertRulesOperations : IServiceOperations, ISmartDetectorAlertRulesOperations + { + /// + /// Initializes a new instance of the SmartDetectorAlertRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SmartDetectorAlertRulesOperations(AlertsManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AlertsManagementClient + /// + public AlertsManagementClient Client { get; private set; } + + /// + /// List all the existing Smart Detector alert rules within the subscription. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(bool? expandDetector = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-06-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("expandDetector", expandDetector); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules").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 (expandDetector != null) + { + _queryParameters.Add(string.Format("expandDetector={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(expandDetector, Client.SerializationSettings).Trim('"')))); + } + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _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 all the existing Smart Detector alert rules within the subscription + /// and resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// 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, bool? expandDetector = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + string apiVersion = "2019-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("expandDetector", expandDetector); + 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.alertsManagement/smartDetectorAlertRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (expandDetector != null) + { + _queryParameters.Add(string.Format("expandDetector={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(expandDetector, Client.SerializationSettings).Trim('"')))); + } + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a specific Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// 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 alertRuleName, bool? expandDetector = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (alertRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertRuleName"); + } + string apiVersion = "2019-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("alertRuleName", alertRuleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("expandDetector", expandDetector); + 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.alertsManagement/smartDetectorAlertRules/{alertRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{alertRuleName}", System.Uri.EscapeDataString(alertRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (expandDetector != null) + { + _queryParameters.Add(string.Format("expandDetector={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(expandDetector, Client.SerializationSettings).Trim('"')))); + } + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update a Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string alertRuleName, AlertRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (alertRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertRuleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2019-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("alertRuleName", alertRuleName); + 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.alertsManagement/smartDetectorAlertRules/{alertRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{alertRuleName}", System.Uri.EscapeDataString(alertRuleName)); + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _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; + } + + /// + /// Patch a specific Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> PatchWithHttpMessagesAsync(string resourceGroupName, string alertRuleName, AlertRulePatchObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (alertRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertRuleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2019-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("alertRuleName", alertRuleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Patch", 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.alertsManagement/smartDetectorAlertRules/{alertRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{alertRuleName}", System.Uri.EscapeDataString(alertRuleName)); + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete an existing Smart Detector alert rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert 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 alertRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (alertRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertRuleName"); + } + string apiVersion = "2019-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("alertRuleName", alertRuleName); + 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.alertsManagement/smartDetectorAlertRules/{alertRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{alertRuleName}", System.Uri.EscapeDataString(alertRuleName)); + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _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 all the existing Smart Detector alert rules within the 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>> ListNextWithHttpMessagesAsync(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, "ListNext", 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) + { + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _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 all the existing Smart Detector alert rules within the subscription + /// and resource group. + /// + /// + /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(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, "ListByResourceGroupNext", 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) + { + 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 ErrorResponse1Exception(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse1 _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/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperationsExtensions.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperationsExtensions.cs new file mode 100644 index 000000000000..fe8da9b4c734 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartDetectorAlertRulesOperationsExtensions.cs @@ -0,0 +1,346 @@ +// +// 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.AlertsManagement +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SmartDetectorAlertRulesOperations. + /// + public static partial class SmartDetectorAlertRulesOperationsExtensions + { + /// + /// List all the existing Smart Detector alert rules within the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + public static IPage List(this ISmartDetectorAlertRulesOperations operations, bool? expandDetector = default(bool?)) + { + return operations.ListAsync(expandDetector).GetAwaiter().GetResult(); + } + + /// + /// List all the existing Smart Detector alert rules within the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISmartDetectorAlertRulesOperations operations, bool? expandDetector = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(expandDetector, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the existing Smart Detector alert rules within the subscription + /// and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + public static IPage ListByResourceGroup(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, bool? expandDetector = default(bool?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, expandDetector).GetAwaiter().GetResult(); + } + + /// + /// List all the existing Smart Detector alert rules within the subscription + /// and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, bool? expandDetector = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, expandDetector, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a specific Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + public static AlertRule Get(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, bool? expandDetector = default(bool?)) + { + return operations.GetAsync(resourceGroupName, alertRuleName, expandDetector).GetAwaiter().GetResult(); + } + + /// + /// Get a specific Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Indicates if Smart Detector should be expanded. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, bool? expandDetector = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, alertRuleName, expandDetector, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + public static AlertRule CreateOrUpdate(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, AlertRule parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, alertRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update a Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, AlertRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, alertRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Patch a specific Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + public static AlertRule Patch(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, AlertRulePatchObject parameters) + { + return operations.PatchAsync(resourceGroupName, alertRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Patch a specific Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task PatchAsync(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, AlertRulePatchObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PatchWithHttpMessagesAsync(resourceGroupName, alertRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an existing Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + public static void Delete(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName) + { + operations.DeleteAsync(resourceGroupName, alertRuleName).GetAwaiter().GetResult(); + } + + /// + /// Delete an existing Smart Detector alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the alert rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISmartDetectorAlertRulesOperations operations, string resourceGroupName, string alertRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, alertRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List all the existing Smart Detector alert rules within the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISmartDetectorAlertRulesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all the existing Smart Detector alert rules within the 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> ListNextAsync(this ISmartDetectorAlertRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the existing Smart Detector alert rules within the subscription + /// and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this ISmartDetectorAlertRulesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all the existing Smart Detector alert rules within the subscription + /// and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this ISmartDetectorAlertRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartGroupsOperations.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartGroupsOperations.cs index bc8f92daefe0..be1333aea1f6 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartGroupsOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartGroupsOperations.cs @@ -132,6 +132,14 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -150,6 +158,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) tracingParameters.Add("pageCount", pageCount); tracingParameters.Add("sortBy", sortBy); tracingParameters.Add("sortOrder", sortOrder); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetAll", tracingParameters); } @@ -202,9 +211,9 @@ internal SmartGroupsOperations(AlertsManagementClient client) { _queryParameters.Add(string.Format("sortOrder={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(sortOrder, Client.SerializationSettings).Trim('"')))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -362,10 +371,18 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (smartGroupId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "smartGroupId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -374,6 +391,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("smartGroupId", smartGroupId); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetById", tracingParameters); } @@ -383,9 +401,9 @@ internal SmartGroupsOperations(AlertsManagementClient client) _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{smartGroupId}", System.Uri.EscapeDataString(smartGroupId)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -557,6 +575,13 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (smartGroupId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "smartGroupId"); @@ -565,6 +590,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "newState"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -573,6 +599,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("smartGroupId", smartGroupId); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("newState", newState); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ChangeState", tracingParameters); @@ -583,9 +610,9 @@ internal SmartGroupsOperations(AlertsManagementClient client) _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{smartGroupId}", System.Uri.EscapeDataString(smartGroupId)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (newState != null) { @@ -758,10 +785,18 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } if (smartGroupId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "smartGroupId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -770,6 +805,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("smartGroupId", smartGroupId); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetHistory", tracingParameters); } @@ -779,9 +815,9 @@ internal SmartGroupsOperations(AlertsManagementClient client) _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{smartGroupId}", System.Uri.EscapeDataString(smartGroupId)); List _queryParameters = new List(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) {