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 ddb7be193992b..fa1277753ce0d 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ActionRulesOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/ActionRulesOperations.cs @@ -128,6 +128,7 @@ internal ActionRulesOperations(AlertsManagementClient client) throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); } } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -145,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); } @@ -193,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) { @@ -416,6 +418,7 @@ internal ActionRulesOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -434,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); } @@ -483,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) { @@ -674,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; @@ -683,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); } @@ -693,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) { @@ -895,6 +901,7 @@ internal ActionRulesOperations(AlertsManagementClient client) { actionRule.Validate(); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -905,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); } @@ -915,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) { @@ -1112,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; @@ -1121,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); } @@ -1131,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) { @@ -1329,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; @@ -1339,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); } @@ -1349,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 5c4803a630fb8..fc659eb2b2c55 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsManagementClient.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsManagementClient.cs @@ -51,11 +51,6 @@ public partial class AlertsManagementClient : ServiceClient public string SubscriptionId { get; set; } - /// - /// client API version - /// - public string ApiVersion { get; private set; } - /// /// The preferred language for the response. /// @@ -74,6 +69,11 @@ public partial class AlertsManagementClient : ServiceClient public bool? GenerateClientRequestId { get; set; } + /// + /// Gets the IActionRulesOperations. + /// + public virtual IActionRulesOperations ActionRules { get; private set; } + /// /// Gets the IOperations. /// @@ -90,9 +90,9 @@ public partial class AlertsManagementClient : ServiceClient - /// Gets the IActionRulesOperations. + /// Gets the ISmartDetectorAlertRulesOperations. /// - public virtual IActionRulesOperations ActionRules { get; private set; } + public virtual ISmartDetectorAlertRulesOperations SmartDetectorAlertRules { get; private set; } /// /// Initializes a new instance of the AlertsManagementClient class. @@ -335,12 +335,12 @@ public AlertsManagementClient(System.Uri baseUri, ServiceClientCredentials crede /// private void Initialize() { + ActionRules = new ActionRulesOperations(this); Operations = new Operations(this); 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; 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 74d405140c09c..7c6a16bd894dd 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/AlertsOperations.cs @@ -70,6 +70,7 @@ internal AlertsOperations(AlertsManagementClient client) /// 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; @@ -78,6 +79,7 @@ internal AlertsOperations(AlertsManagementClient client) { _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); @@ -86,9 +88,9 @@ internal AlertsOperations(AlertsManagementClient client) 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 (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 (identifier != null) { @@ -335,6 +337,7 @@ internal AlertsOperations(AlertsManagementClient client) throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); } } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -359,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); } @@ -435,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) { @@ -606,6 +610,7 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -614,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); } @@ -623,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) { @@ -799,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; @@ -807,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); @@ -817,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) { @@ -990,6 +998,7 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "alertId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -998,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); } @@ -1007,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) { @@ -1227,6 +1237,7 @@ internal AlertsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "groupby"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1246,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); } @@ -1302,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/IAlertsManagementClient.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs index 5983738e9d708..ba5d9ab88a671 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/IAlertsManagementClient.cs @@ -45,11 +45,6 @@ public partial interface IAlertsManagementClient : System.IDisposable /// string SubscriptionId { get; set; } - /// - /// client API version - /// - string ApiVersion { get; } - /// /// The preferred language for the response. /// @@ -69,6 +64,11 @@ public partial interface IAlertsManagementClient : System.IDisposable bool? GenerateClientRequestId { get; set; } + /// + /// Gets the IActionRulesOperations. + /// + IActionRulesOperations ActionRules { get; } + /// /// Gets the IOperations. /// @@ -85,9 +85,9 @@ public partial interface IAlertsManagementClient : System.IDisposable ISmartGroupsOperations SmartGroups { get; } /// - /// Gets the IActionRulesOperations. + /// Gets the ISmartDetectorAlertRulesOperations. /// - IActionRulesOperations ActionRules { get; } + ISmartDetectorAlertRulesOperations SmartDetectorAlertRules { get; } } } 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 0000000000000..f3f27dd8c9c30 --- /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/ActionGroupsInformation.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/ActionGroupsInformation.cs new file mode 100644 index 0000000000000..f70748c97f1a1 --- /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/AlertRule.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AlertRule.cs new file mode 100644 index 0000000000000..dfa4dcbe0252f --- /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 0000000000000..c490899c38b76 --- /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 0000000000000..921f7d5ba692d --- /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/AzureResource.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/AzureResource.cs new file mode 100644 index 0000000000000..c93f00c259b96 --- /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 0000000000000..25b2286e9233d --- /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/SmartDetectorErrorResponse.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/SmartDetectorErrorResponse.cs new file mode 100644 index 0000000000000..299e99b60f3ed --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/SmartDetectorErrorResponse.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 SmartDetectorErrorResponse + { + /// + /// Initializes a new instance of the SmartDetectorErrorResponse class. + /// + public SmartDetectorErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SmartDetectorErrorResponse class. + /// + /// Error code + /// Error message indicating why the operation + /// failed. + public SmartDetectorErrorResponse(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/SmartDetectorErrorResponseException.cs b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/SmartDetectorErrorResponseException.cs new file mode 100644 index 0000000000000..ef6a6fae3d294 --- /dev/null +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/Models/SmartDetectorErrorResponseException.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 + /// SmartDetectorErrorResponse information. + /// + public partial class SmartDetectorErrorResponseException : 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 SmartDetectorErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the SmartDetectorErrorResponseException class. + /// + public SmartDetectorErrorResponseException() + { + } + + /// + /// Initializes a new instance of the SmartDetectorErrorResponseException class. + /// + /// The exception message. + public SmartDetectorErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the SmartDetectorErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public SmartDetectorErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} 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 0000000000000..d95264642502d --- /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 16c37fe1dac64..6f06eeda4bdf2 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 index 02e5fe3aad300..e678aff7fe2de 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SdkInfo_AlertsManagementClient.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SdkInfo_AlertsManagementClient.cs @@ -23,19 +23,9 @@ public static IEnumerable> ApiInfo_AlertsManagemen 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(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/alertsmanagement/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --tag=package-preview-2019-05 --csharp-sdks-folder=C:\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "98f100daf12446cbdc6359ba9b34e8a10f8410f3"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - 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 0000000000000..38d0166acf659 --- /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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 SmartDetectorErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + SmartDetectorErrorResponse _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 0000000000000..fe8da9b4c7349 --- /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 866a9a0eec3f6..be1333aea1f65 100644 --- a/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartGroupsOperations.cs +++ b/sdk/alertsmanagement/Microsoft.Azure.Management.AlertsManagement/src/Generated/SmartGroupsOperations.cs @@ -139,6 +139,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); } } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -157,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); } @@ -209,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) { @@ -380,6 +382,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "smartGroupId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -388,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); } @@ -397,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) { @@ -586,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; @@ -594,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); @@ -604,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) { @@ -790,6 +796,7 @@ internal SmartGroupsOperations(AlertsManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "smartGroupId"); } + string apiVersion = "2019-05-05-preview"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -798,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); } @@ -807,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) {