diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperations.cs index 3938fd49d061..524870971a85 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperations.cs @@ -51,7 +51,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) public SecurityCenterClient Client { get; private set; } /// - /// Gets a list of application control VM/server groups for the subscription. + /// Gets a list of application control machine groups for the subscription. /// /// /// Include the policy rules @@ -80,7 +80,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListWithHttpMessagesAsync(bool? includePathRecommendations = default(bool?), bool? summary = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ListWithHttpMessagesAsync(bool? includePathRecommendations = default(bool?), bool? summary = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -217,7 +217,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -230,7 +230,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -253,7 +253,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) /// Gets an application control VM/server group. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// Headers that will be added to request. @@ -276,7 +276,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetWithHttpMessagesAsync(string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -414,7 +414,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -427,7 +427,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -447,10 +447,10 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) } /// - /// Update an application control VM/server group + /// Update an application control machine group /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// @@ -475,7 +475,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task> PutWithHttpMessagesAsync(string groupName, AppWhitelistingGroup body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> PutWithHttpMessagesAsync(string groupName, AdaptiveApplicationControlGroup body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -624,7 +624,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -637,7 +637,7 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -657,10 +657,10 @@ internal AdaptiveApplicationControlsOperations(SecurityCenterClient client) } /// - /// Delete an application control VM/server group + /// Delete an application control machine group /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// Headers that will be added to request. diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperationsExtensions.cs index 73722ded1f71..d43ddfb37085 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperationsExtensions.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdaptiveApplicationControlsOperationsExtensions.cs @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Management.Security public static partial class AdaptiveApplicationControlsOperationsExtensions { /// - /// Gets a list of application control VM/server groups for the subscription. + /// Gets a list of application control machine groups for the subscription. /// /// /// The operations group for this extension method. @@ -33,13 +33,13 @@ public static partial class AdaptiveApplicationControlsOperationsExtensions /// /// Return output in a summarized form /// - public static AppWhitelistingGroups List(this IAdaptiveApplicationControlsOperations operations, bool? includePathRecommendations = default(bool?), bool? summary = default(bool?)) + public static AdaptiveApplicationControlGroups List(this IAdaptiveApplicationControlsOperations operations, bool? includePathRecommendations = default(bool?), bool? summary = default(bool?)) { return operations.ListAsync(includePathRecommendations, summary).GetAwaiter().GetResult(); } /// - /// Gets a list of application control VM/server groups for the subscription. + /// Gets a list of application control machine groups for the subscription. /// /// /// The operations group for this extension method. @@ -53,7 +53,7 @@ public static partial class AdaptiveApplicationControlsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListAsync(this IAdaptiveApplicationControlsOperations operations, bool? includePathRecommendations = default(bool?), bool? summary = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task ListAsync(this IAdaptiveApplicationControlsOperations operations, bool? includePathRecommendations = default(bool?), bool? summary = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListWithHttpMessagesAsync(includePathRecommendations, summary, null, cancellationToken).ConfigureAwait(false)) { @@ -68,9 +68,9 @@ public static partial class AdaptiveApplicationControlsOperationsExtensions /// The operations group for this extension method. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// - public static AppWhitelistingGroup Get(this IAdaptiveApplicationControlsOperations operations, string groupName) + public static AdaptiveApplicationControlGroup Get(this IAdaptiveApplicationControlsOperations operations, string groupName) { return operations.GetAsync(groupName).GetAwaiter().GetResult(); } @@ -82,12 +82,12 @@ public static AppWhitelistingGroup Get(this IAdaptiveApplicationControlsOperatio /// The operations group for this extension method. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// The cancellation token. /// - public static async Task GetAsync(this IAdaptiveApplicationControlsOperations operations, string groupName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task GetAsync(this IAdaptiveApplicationControlsOperations operations, string groupName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetWithHttpMessagesAsync(groupName, null, cancellationToken).ConfigureAwait(false)) { @@ -96,36 +96,36 @@ public static AppWhitelistingGroup Get(this IAdaptiveApplicationControlsOperatio } /// - /// Update an application control VM/server group + /// Update an application control machine group /// /// /// The operations group for this extension method. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// - public static AppWhitelistingGroup Put(this IAdaptiveApplicationControlsOperations operations, string groupName, AppWhitelistingGroup body) + public static AdaptiveApplicationControlGroup Put(this IAdaptiveApplicationControlsOperations operations, string groupName, AdaptiveApplicationControlGroup body) { return operations.PutAsync(groupName, body).GetAwaiter().GetResult(); } /// - /// Update an application control VM/server group + /// Update an application control machine group /// /// /// The operations group for this extension method. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// /// /// The cancellation token. /// - public static async Task PutAsync(this IAdaptiveApplicationControlsOperations operations, string groupName, AppWhitelistingGroup body, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task PutAsync(this IAdaptiveApplicationControlsOperations operations, string groupName, AdaptiveApplicationControlGroup body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.PutWithHttpMessagesAsync(groupName, body, null, cancellationToken).ConfigureAwait(false)) { @@ -134,13 +134,13 @@ public static AppWhitelistingGroup Put(this IAdaptiveApplicationControlsOperatio } /// - /// Delete an application control VM/server group + /// Delete an application control machine group /// /// /// The operations group for this extension method. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// public static void Delete(this IAdaptiveApplicationControlsOperations operations, string groupName) { @@ -148,13 +148,13 @@ public static void Delete(this IAdaptiveApplicationControlsOperations operations } /// - /// Delete an application control VM/server group + /// Delete an application control machine group /// /// /// The operations group for this extension method. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// The cancellation token. diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdvancedThreatProtectionOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdvancedThreatProtectionOperations.cs index 8f1f65d9ee66..13a4681b3563 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdvancedThreatProtectionOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AdvancedThreatProtectionOperations.cs @@ -101,7 +101,7 @@ internal AdvancedThreatProtectionOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{settingName}", System.Uri.EscapeDataString(settingName)); List _queryParameters = new List(); if (apiVersion != null) @@ -294,7 +294,7 @@ internal AdvancedThreatProtectionOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{settingName}", System.Uri.EscapeDataString(settingName)); List _queryParameters = new List(); if (apiVersion != null) diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperations.cs index c3eeac560762..2db369a32189 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperations.cs @@ -53,15 +53,6 @@ internal AlertsOperations(SecurityCenterClient client) /// /// List all the alerts that are associated with the subscription /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// Headers that will be added to request. /// @@ -83,7 +74,7 @@ internal AlertsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListWithHttpMessagesAsync(string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -96,7 +87,7 @@ internal AlertsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); } } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -105,9 +96,6 @@ internal AlertsOperations(SecurityCenterClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("filter", filter); - tracingParameters.Add("select", select); - tracingParameters.Add("expand", expand); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } @@ -120,18 +108,6 @@ internal AlertsOperations(SecurityCenterClient client) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } - if (filter != null) - { - _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); - } - if (select != null) - { - _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -264,15 +240,6 @@ internal AlertsOperations(SecurityCenterClient client) /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// Headers that will be added to request. /// @@ -294,7 +261,7 @@ internal AlertsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -326,7 +293,7 @@ internal AlertsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); } } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -336,9 +303,6 @@ internal AlertsOperations(SecurityCenterClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("filter", filter); - tracingParameters.Add("select", select); - tracingParameters.Add("expand", expand); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); } @@ -352,18 +316,6 @@ internal AlertsOperations(SecurityCenterClient client) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } - if (filter != null) - { - _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); - } - if (select != null) - { - _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -493,15 +445,6 @@ internal AlertsOperations(SecurityCenterClient client) /// List all the alerts that are associated with the subscription that are /// stored in a specific location /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// Headers that will be added to request. /// @@ -523,7 +466,7 @@ internal AlertsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListSubscriptionLevelAlertsByRegionWithHttpMessagesAsync(string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListSubscriptionLevelAlertsByRegionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -540,7 +483,7 @@ internal AlertsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -549,9 +492,6 @@ internal AlertsOperations(SecurityCenterClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("filter", filter); - tracingParameters.Add("select", select); - tracingParameters.Add("expand", expand); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListSubscriptionLevelAlertsByRegion", tracingParameters); } @@ -565,18 +505,6 @@ internal AlertsOperations(SecurityCenterClient client) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } - if (filter != null) - { - _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); - } - if (select != null) - { - _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -710,15 +638,6 @@ internal AlertsOperations(SecurityCenterClient client) /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// Headers that will be added to request. /// @@ -740,7 +659,7 @@ internal AlertsOperations(SecurityCenterClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListResourceGroupLevelAlertsByRegionWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListResourceGroupLevelAlertsByRegionWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -776,7 +695,7 @@ internal AlertsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); } } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -786,9 +705,6 @@ internal AlertsOperations(SecurityCenterClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("filter", filter); - tracingParameters.Add("select", select); - tracingParameters.Add("expand", expand); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListResourceGroupLevelAlertsByRegion", tracingParameters); } @@ -803,18 +719,6 @@ internal AlertsOperations(SecurityCenterClient client) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } - if (filter != null) - { - _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); - } - if (select != null) - { - _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); - } - if (expand != null) - { - _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); - } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -988,7 +892,7 @@ internal AlertsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "alertName"); } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1209,7 +1113,7 @@ internal AlertsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); } } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1405,7 +1309,7 @@ internal AlertsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "alertName"); } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1536,6 +1440,182 @@ internal AlertsOperations(SecurityCenterClient client) return _result; } + /// + /// Update the alert's state + /// + /// + /// Name of the alert object + /// + /// + /// 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 UpdateSubscriptionLevelStateToResolveWithHttpMessagesAsync(string alertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (Client.AscLocation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); + } + if (alertName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertName"); + } + string apiVersion = "2020-01-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("alertName", alertName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateSubscriptionLevelStateToResolve", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{ascLocation}", System.Uri.EscapeDataString(Client.AscLocation)); + _url = _url.Replace("{alertName}", System.Uri.EscapeDataString(alertName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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 != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// Update the alert's state /// @@ -1581,7 +1661,7 @@ internal AlertsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "alertName"); } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1596,10 +1676,211 @@ internal AlertsOperations(SecurityCenterClient client) } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{ascLocation}", System.Uri.EscapeDataString(Client.AscLocation)); + _url = _url.Replace("{alertName}", System.Uri.EscapeDataString(alertName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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 != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update the alert's state + /// + /// + /// Name of the alert object + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// 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 UpdateResourceGroupLevelStateToResolveWithHttpMessagesAsync(string alertName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (Client.AscLocation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); + } + if (alertName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertName"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + string apiVersion = "2020-01-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("alertName", alertName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateResourceGroupLevelStateToResolve", 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.Security/locations/{ascLocation}/alerts/{alertName}/resolve").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{ascLocation}", System.Uri.EscapeDataString(Client.AscLocation)); _url = _url.Replace("{alertName}", System.Uri.EscapeDataString(alertName)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); List _queryParameters = new List(); if (apiVersion != null) { @@ -1780,7 +2061,7 @@ internal AlertsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); } } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1981,7 +2262,7 @@ internal AlertsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); } } - string apiVersion = "2019-01-01"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1997,7 +2278,7 @@ internal AlertsOperations(SecurityCenterClient client) } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{ascLocation}", System.Uri.EscapeDataString(Client.AscLocation)); _url = _url.Replace("{alertName}", System.Uri.EscapeDataString(alertName)); diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperationsExtensions.cs index b0c9b6285371..a6fa8ea8e4ad 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperationsExtensions.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsOperationsExtensions.cs @@ -27,18 +27,9 @@ public static partial class AlertsOperationsExtensions /// /// The operations group for this extension method. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// - public static IPage List(this IAlertsOperations operations, string filter = default(string), string select = default(string), string expand = default(string)) + public static IPage List(this IAlertsOperations operations) { - return operations.ListAsync(filter, select, expand).GetAwaiter().GetResult(); + return operations.ListAsync().GetAwaiter().GetResult(); } /// @@ -47,21 +38,12 @@ public static partial class AlertsOperationsExtensions /// /// The operations group for this extension method. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The cancellation token. /// - public static async Task> ListAsync(this IAlertsOperations operations, string filter = default(string), string select = default(string), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListAsync(this IAlertsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListWithHttpMessagesAsync(filter, select, expand, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -77,18 +59,9 @@ public static partial class AlertsOperationsExtensions /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// - public static IPage ListByResourceGroup(this IAlertsOperations operations, string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string)) + public static IPage ListByResourceGroup(this IAlertsOperations operations, string resourceGroupName) { - return operations.ListByResourceGroupAsync(resourceGroupName, filter, select, expand).GetAwaiter().GetResult(); + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); } /// @@ -101,21 +74,12 @@ public static partial class AlertsOperationsExtensions /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The cancellation token. /// - public static async Task> ListByResourceGroupAsync(this IAlertsOperations operations, string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListByResourceGroupAsync(this IAlertsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, select, expand, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -128,18 +92,9 @@ public static partial class AlertsOperationsExtensions /// /// The operations group for this extension method. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// - public static IPage ListSubscriptionLevelAlertsByRegion(this IAlertsOperations operations, string filter = default(string), string select = default(string), string expand = default(string)) + public static IPage ListSubscriptionLevelAlertsByRegion(this IAlertsOperations operations) { - return operations.ListSubscriptionLevelAlertsByRegionAsync(filter, select, expand).GetAwaiter().GetResult(); + return operations.ListSubscriptionLevelAlertsByRegionAsync().GetAwaiter().GetResult(); } /// @@ -149,21 +104,12 @@ public static partial class AlertsOperationsExtensions /// /// The operations group for this extension method. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The cancellation token. /// - public static async Task> ListSubscriptionLevelAlertsByRegionAsync(this IAlertsOperations operations, string filter = default(string), string select = default(string), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListSubscriptionLevelAlertsByRegionAsync(this IAlertsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListSubscriptionLevelAlertsByRegionWithHttpMessagesAsync(filter, select, expand, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.ListSubscriptionLevelAlertsByRegionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -180,18 +126,9 @@ public static partial class AlertsOperationsExtensions /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// - public static IPage ListResourceGroupLevelAlertsByRegion(this IAlertsOperations operations, string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string)) + public static IPage ListResourceGroupLevelAlertsByRegion(this IAlertsOperations operations, string resourceGroupName) { - return operations.ListResourceGroupLevelAlertsByRegionAsync(resourceGroupName, filter, select, expand).GetAwaiter().GetResult(); + return operations.ListResourceGroupLevelAlertsByRegionAsync(resourceGroupName).GetAwaiter().GetResult(); } /// @@ -205,21 +142,12 @@ public static partial class AlertsOperationsExtensions /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The cancellation token. /// - public static async Task> ListResourceGroupLevelAlertsByRegionAsync(this IAlertsOperations operations, string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListResourceGroupLevelAlertsByRegionAsync(this IAlertsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListResourceGroupLevelAlertsByRegionWithHttpMessagesAsync(resourceGroupName, filter, select, expand, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.ListResourceGroupLevelAlertsByRegionWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -334,6 +262,37 @@ public static void UpdateSubscriptionLevelAlertStateToDismiss(this IAlertsOperat (await operations.UpdateSubscriptionLevelAlertStateToDismissWithHttpMessagesAsync(alertName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } + /// + /// Update the alert's state + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the alert object + /// + public static void UpdateSubscriptionLevelStateToResolve(this IAlertsOperations operations, string alertName) + { + operations.UpdateSubscriptionLevelStateToResolveAsync(alertName).GetAwaiter().GetResult(); + } + + /// + /// Update the alert's state + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the alert object + /// + /// + /// The cancellation token. + /// + public static async Task UpdateSubscriptionLevelStateToResolveAsync(this IAlertsOperations operations, string alertName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.UpdateSubscriptionLevelStateToResolveWithHttpMessagesAsync(alertName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// /// Update the alert's state /// @@ -365,6 +324,45 @@ public static void UpdateSubscriptionLevelAlertStateToReactivate(this IAlertsOpe (await operations.UpdateSubscriptionLevelAlertStateToReactivateWithHttpMessagesAsync(alertName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } + /// + /// Update the alert's state + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the alert object + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + public static void UpdateResourceGroupLevelStateToResolve(this IAlertsOperations operations, string alertName, string resourceGroupName) + { + operations.UpdateResourceGroupLevelStateToResolveAsync(alertName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Update the alert's state + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the alert object + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateResourceGroupLevelStateToResolveAsync(this IAlertsOperations operations, string alertName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.UpdateResourceGroupLevelStateToResolveWithHttpMessagesAsync(alertName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// /// Update the alert's state /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsSuppressionRulesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsSuppressionRulesOperations.cs new file mode 100644 index 000000000000..218a659c1e10 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsSuppressionRulesOperations.cs @@ -0,0 +1,992 @@ +// +// 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.Security +{ + 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; + + /// + /// AlertsSuppressionRulesOperations operations. + /// + internal partial class AlertsSuppressionRulesOperations : IServiceOperations, IAlertsSuppressionRulesOperations + { + /// + /// Initializes a new instance of the AlertsSuppressionRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AlertsSuppressionRulesOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List of all the dismiss rules for the given subscription + /// + /// + /// Type of the alert to get rules for + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string alertType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2019-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("alertType", alertType); + 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.Security/alertsSuppressionRules").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 (alertType != null) + { + _queryParameters.Add(string.Format("AlertType={0}", System.Uri.EscapeDataString(alertType))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given + /// subscription + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string alertsSuppressionRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (alertsSuppressionRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertsSuppressionRuleName"); + } + string apiVersion = "2019-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("alertsSuppressionRuleName", alertsSuppressionRuleName); + 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}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{alertsSuppressionRuleName}", System.Uri.EscapeDataString(alertsSuppressionRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update existing rule or create new rule if it doesn't exist + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// Suppression rule object + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string alertsSuppressionRuleName, AlertsSuppressionRule alertsSuppressionRule, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (alertsSuppressionRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertsSuppressionRuleName"); + } + if (alertsSuppressionRule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertsSuppressionRule"); + } + if (alertsSuppressionRule != null) + { + alertsSuppressionRule.Validate(); + } + string apiVersion = "2019-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("alertsSuppressionRuleName", alertsSuppressionRuleName); + tracingParameters.Add("alertsSuppressionRule", alertsSuppressionRule); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{alertsSuppressionRuleName}", System.Uri.EscapeDataString(alertsSuppressionRuleName)); + 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(alertsSuppressionRule != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(alertsSuppressionRule, 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete dismiss alert rule for this subscription. + /// + /// + /// The unique name of the suppression 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 alertsSuppressionRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (alertsSuppressionRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertsSuppressionRuleName"); + } + string apiVersion = "2019-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("alertsSuppressionRuleName", alertsSuppressionRuleName); + 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}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{alertsSuppressionRuleName}", System.Uri.EscapeDataString(alertsSuppressionRuleName)); + 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 != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List of all the dismiss rules for the given 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsSuppressionRulesOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsSuppressionRulesOperationsExtensions.cs new file mode 100644 index 000000000000..d1d174bcfe3a --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AlertsSuppressionRulesOperationsExtensions.cs @@ -0,0 +1,200 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AlertsSuppressionRulesOperations. + /// + public static partial class AlertsSuppressionRulesOperationsExtensions + { + /// + /// List of all the dismiss rules for the given subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Type of the alert to get rules for + /// + public static IPage List(this IAlertsSuppressionRulesOperations operations, string alertType = default(string)) + { + return operations.ListAsync(alertType).GetAwaiter().GetResult(); + } + + /// + /// List of all the dismiss rules for the given subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Type of the alert to get rules for + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IAlertsSuppressionRulesOperations operations, string alertType = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(alertType, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given + /// subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The unique name of the suppression alert rule + /// + public static AlertsSuppressionRule Get(this IAlertsSuppressionRulesOperations operations, string alertsSuppressionRuleName) + { + return operations.GetAsync(alertsSuppressionRuleName).GetAwaiter().GetResult(); + } + + /// + /// Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given + /// subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAlertsSuppressionRulesOperations operations, string alertsSuppressionRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(alertsSuppressionRuleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update existing rule or create new rule if it doesn't exist + /// + /// + /// The operations group for this extension method. + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// Suppression rule object + /// + public static AlertsSuppressionRule Update(this IAlertsSuppressionRulesOperations operations, string alertsSuppressionRuleName, AlertsSuppressionRule alertsSuppressionRule) + { + return operations.UpdateAsync(alertsSuppressionRuleName, alertsSuppressionRule).GetAwaiter().GetResult(); + } + + /// + /// Update existing rule or create new rule if it doesn't exist + /// + /// + /// The operations group for this extension method. + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// Suppression rule object + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAlertsSuppressionRulesOperations operations, string alertsSuppressionRuleName, AlertsSuppressionRule alertsSuppressionRule, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(alertsSuppressionRuleName, alertsSuppressionRule, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete dismiss alert rule for this subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The unique name of the suppression alert rule + /// + public static void Delete(this IAlertsSuppressionRulesOperations operations, string alertsSuppressionRuleName) + { + operations.DeleteAsync(alertsSuppressionRuleName).GetAwaiter().GetResult(); + } + + /// + /// Delete dismiss alert rule for this subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAlertsSuppressionRulesOperations operations, string alertsSuppressionRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(alertsSuppressionRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List of all the dismiss rules for the given subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IAlertsSuppressionRulesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List of all the dismiss rules for the given 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 IAlertsSuppressionRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AssessmentsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AssessmentsOperations.cs index 9204237839ed..1c5f938d1b19 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AssessmentsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/AssessmentsOperations.cs @@ -101,7 +101,7 @@ internal AssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/assessments").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); List _queryParameters = new List(); if (apiVersion != null) { @@ -293,7 +293,7 @@ internal AssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{assessmentName}", System.Uri.EscapeDataString(assessmentName)); List _queryParameters = new List(); if (apiVersion != null) @@ -500,7 +500,7 @@ internal AssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{assessmentName}", System.Uri.EscapeDataString(assessmentName)); List _queryParameters = new List(); if (apiVersion != null) @@ -712,7 +712,7 @@ internal AssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{assessmentName}", System.Uri.EscapeDataString(assessmentName)); List _queryParameters = new List(); if (apiVersion != null) diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ComplianceResultsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ComplianceResultsOperations.cs index bc3295d06fb8..bcdd9739ba99 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ComplianceResultsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ComplianceResultsOperations.cs @@ -101,7 +101,7 @@ internal ComplianceResultsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/complianceResults").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); List _queryParameters = new List(); if (apiVersion != null) { @@ -289,7 +289,7 @@ internal ComplianceResultsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{complianceResultName}", System.Uri.EscapeDataString(complianceResultName)); List _queryParameters = new List(); if (apiVersion != null) diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/CompliancesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/CompliancesOperations.cs index 301070d6be91..307faa6dcacc 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/CompliancesOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/CompliancesOperations.cs @@ -101,7 +101,7 @@ internal CompliancesOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/compliances").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); List _queryParameters = new List(); if (apiVersion != null) { @@ -291,7 +291,7 @@ internal CompliancesOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/compliances/{complianceName}").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); _url = _url.Replace("{complianceName}", System.Uri.EscapeDataString(complianceName)); List _queryParameters = new List(); if (apiVersion != null) diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ConnectorsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ConnectorsOperations.cs new file mode 100644 index 000000000000..0c991b90f231 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ConnectorsOperations.cs @@ -0,0 +1,992 @@ +// +// 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.Security +{ + 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; + + /// + /// ConnectorsOperations operations. + /// + internal partial class ConnectorsOperations : IServiceOperations, IConnectorsOperations + { + /// + /// Initializes a new instance of the ConnectorsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ConnectorsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Details of a specific cloud account connector + /// + /// + /// Name of the cloud account connector + /// + /// + /// 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 connectorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (connectorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "connectorName"); + } + string apiVersion = "2020-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("connectorName", connectorName); + 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}/providers/Microsoft.Security/connectors/{connectorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{connectorName}", System.Uri.EscapeDataString(connectorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a cloud account connector or update an existing one. Connect to your + /// cloud account. For AWS, use either account credentials or role-based + /// authentication. For GCP, use account organization credentials. + /// + /// + /// Name of the cloud account connector + /// + /// + /// Settings for hybrid compute management. These settings are relevant only + /// for Arc autoProvision (Hybrid Compute). + /// + /// + /// Settings for authentication management, these settings are relevant only + /// for the cloud connector. + /// + /// + /// 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 connectorName, HybridComputeSettingsProperties hybridComputeSettings = default(HybridComputeSettingsProperties), AuthenticationDetailsProperties authenticationDetails = default(AuthenticationDetailsProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (connectorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "connectorName"); + } + if (hybridComputeSettings != null) + { + hybridComputeSettings.Validate(); + } + string apiVersion = "2020-01-01-preview"; + ConnectorSetting connectorSetting = new ConnectorSetting(); + if (hybridComputeSettings != null || authenticationDetails != null) + { + connectorSetting.HybridComputeSettings = hybridComputeSettings; + connectorSetting.AuthenticationDetails = authenticationDetails; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("connectorName", connectorName); + tracingParameters.Add("connectorSetting", connectorSetting); + 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}/providers/Microsoft.Security/connectors/{connectorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{connectorName}", System.Uri.EscapeDataString(connectorName)); + 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(connectorSetting != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(connectorSetting, 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a cloud account connector from a subscription + /// + /// + /// Name of the cloud account connector + /// + /// + /// 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 connectorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (connectorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "connectorName"); + } + string apiVersion = "2020-01-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("connectorName", connectorName); + 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}/providers/Microsoft.Security/connectors/{connectorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{connectorName}", System.Uri.EscapeDataString(connectorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ConnectorsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ConnectorsOperationsExtensions.cs new file mode 100644 index 000000000000..448906574d71 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ConnectorsOperationsExtensions.cs @@ -0,0 +1,206 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ConnectorsOperations. + /// + public static partial class ConnectorsOperationsExtensions + { + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IConnectorsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IConnectorsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Details of a specific cloud account connector + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the cloud account connector + /// + public static ConnectorSetting Get(this IConnectorsOperations operations, string connectorName) + { + return operations.GetAsync(connectorName).GetAwaiter().GetResult(); + } + + /// + /// Details of a specific cloud account connector + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the cloud account connector + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IConnectorsOperations operations, string connectorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(connectorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a cloud account connector or update an existing one. Connect to your + /// cloud account. For AWS, use either account credentials or role-based + /// authentication. For GCP, use account organization credentials. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the cloud account connector + /// + /// + /// Settings for hybrid compute management. These settings are relevant only + /// for Arc autoProvision (Hybrid Compute). + /// + /// + /// Settings for authentication management, these settings are relevant only + /// for the cloud connector. + /// + public static ConnectorSetting CreateOrUpdate(this IConnectorsOperations operations, string connectorName, HybridComputeSettingsProperties hybridComputeSettings = default(HybridComputeSettingsProperties), AuthenticationDetailsProperties authenticationDetails = default(AuthenticationDetailsProperties)) + { + return operations.CreateOrUpdateAsync(connectorName, hybridComputeSettings, authenticationDetails).GetAwaiter().GetResult(); + } + + /// + /// Create a cloud account connector or update an existing one. Connect to your + /// cloud account. For AWS, use either account credentials or role-based + /// authentication. For GCP, use account organization credentials. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the cloud account connector + /// + /// + /// Settings for hybrid compute management. These settings are relevant only + /// for Arc autoProvision (Hybrid Compute). + /// + /// + /// Settings for authentication management, these settings are relevant only + /// for the cloud connector. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IConnectorsOperations operations, string connectorName, HybridComputeSettingsProperties hybridComputeSettings = default(HybridComputeSettingsProperties), AuthenticationDetailsProperties authenticationDetails = default(AuthenticationDetailsProperties), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(connectorName, hybridComputeSettings, authenticationDetails, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a cloud account connector from a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the cloud account connector + /// + public static void Delete(this IConnectorsOperations operations, string connectorName) + { + operations.DeleteAsync(connectorName).GetAwaiter().GetResult(); + } + + /// + /// Delete a cloud account connector from a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the cloud account connector + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IConnectorsOperations operations, string connectorName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(connectorName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IConnectorsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IConnectorsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceOperations.cs new file mode 100644 index 000000000000..fdf84d888ffd --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceOperations.cs @@ -0,0 +1,243 @@ +// +// 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.Security +{ + 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; + + /// + /// DeviceOperations operations. + /// + internal partial class DeviceOperations : IServiceOperations, IDeviceOperations + { + /// + /// Initializes a new instance of the DeviceOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DeviceOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Get device. + /// + /// + /// The identifier of the resource. + /// + /// + /// Identifier of the device. + /// + /// + /// 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 resourceId, string deviceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (deviceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deviceId"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("deviceId", deviceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/devices/{deviceId}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + _url = _url.Replace("{deviceId}", System.Uri.EscapeDataString(deviceId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceOperationsExtensions.cs new file mode 100644 index 000000000000..b5f731974a69 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceOperationsExtensions.cs @@ -0,0 +1,65 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DeviceOperations. + /// + public static partial class DeviceOperationsExtensions + { + /// + /// Get device. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Identifier of the device. + /// + public static Device Get(this IDeviceOperations operations, string resourceId, string deviceId) + { + return operations.GetAsync(resourceId, deviceId).GetAwaiter().GetResult(); + } + + /// + /// Get device. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Identifier of the device. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDeviceOperations operations, string resourceId, string deviceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceId, deviceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceSecurityGroupsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceSecurityGroupsOperations.cs index 6e980ad08309..5b6b3778b606 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceSecurityGroupsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DeviceSecurityGroupsOperations.cs @@ -100,7 +100,7 @@ internal DeviceSecurityGroupsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/deviceSecurityGroups").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); List _queryParameters = new List(); if (apiVersion != null) { @@ -290,7 +290,7 @@ internal DeviceSecurityGroupsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{deviceSecurityGroupName}", System.Uri.EscapeDataString(deviceSecurityGroupName)); List _queryParameters = new List(); if (apiVersion != null) @@ -489,7 +489,7 @@ internal DeviceSecurityGroupsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{deviceSecurityGroupName}", System.Uri.EscapeDataString(deviceSecurityGroupName)); List _queryParameters = new List(); if (apiVersion != null) @@ -700,7 +700,7 @@ internal DeviceSecurityGroupsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}").ToString(); - _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{resourceId}", resourceId); _url = _url.Replace("{deviceSecurityGroupName}", System.Uri.EscapeDataString(deviceSecurityGroupName)); List _queryParameters = new List(); if (apiVersion != null) diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForHubOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForHubOperations.cs new file mode 100644 index 000000000000..c152521ca69d --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForHubOperations.cs @@ -0,0 +1,432 @@ +// +// 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.Security +{ + 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; + + /// + /// DevicesForHubOperations operations. + /// + internal partial class DevicesForHubOperations : IServiceOperations, IDevicesForHubOperations + { + /// + /// Initializes a new instance of the DevicesForHubOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DevicesForHubOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceId, int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("limit", limit); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("deviceManagementType", deviceManagementType); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/devices").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (limit != null) + { + _queryParameters.Add(string.Format("$limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (deviceManagementType != null) + { + _queryParameters.Add(string.Format("deviceManagementType={0}", System.Uri.EscapeDataString(deviceManagementType))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForHubOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForHubOperationsExtensions.cs new file mode 100644 index 000000000000..fd720b59218f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForHubOperationsExtensions.cs @@ -0,0 +1,113 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DevicesForHubOperations. + /// + public static partial class DevicesForHubOperationsExtensions + { + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + public static IPage List(this IDevicesForHubOperations operations, string resourceId, int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string)) + { + return operations.ListAsync(resourceId, limit, skipToken, deviceManagementType).GetAwaiter().GetResult(); + } + + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDevicesForHubOperations operations, string resourceId, int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceId, limit, skipToken, deviceManagementType, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IDevicesForHubOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// 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 IDevicesForHubOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForSubscriptionOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForSubscriptionOperations.cs new file mode 100644 index 000000000000..3a225ef704bc --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForSubscriptionOperations.cs @@ -0,0 +1,435 @@ +// +// 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.Security +{ + 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; + + /// + /// DevicesForSubscriptionOperations operations. + /// + internal partial class DevicesForSubscriptionOperations : IServiceOperations, IDevicesForSubscriptionOperations + { + /// + /// Initializes a new instance of the DevicesForSubscriptionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DevicesForSubscriptionOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Get list of the devices by their subscription. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// 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(int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("limit", limit); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("deviceManagementType", deviceManagementType); + 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.Security/devices").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 (limit != null) + { + _queryParameters.Add(string.Format("$limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (deviceManagementType != null) + { + _queryParameters.Add(string.Format("deviceManagementType={0}", System.Uri.EscapeDataString(deviceManagementType))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get list of the devices by their 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForSubscriptionOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForSubscriptionOperationsExtensions.cs new file mode 100644 index 000000000000..0e7a5eb6e2fd --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DevicesForSubscriptionOperationsExtensions.cs @@ -0,0 +1,107 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DevicesForSubscriptionOperations. + /// + public static partial class DevicesForSubscriptionOperationsExtensions + { + /// + /// Get list of the devices by their subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + public static IPage List(this IDevicesForSubscriptionOperations operations, int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string)) + { + return operations.ListAsync(limit, skipToken, deviceManagementType).GetAwaiter().GetResult(); + } + + /// + /// Get list of the devices by their subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDevicesForSubscriptionOperations operations, int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(limit, skipToken, deviceManagementType, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get list of the devices by their subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IDevicesForSubscriptionOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get list of the devices by their 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 IDevicesForSubscriptionOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DiscoveredSecuritySolutionsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DiscoveredSecuritySolutionsOperations.cs index b359d01b3d1f..986b60e872f0 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DiscoveredSecuritySolutionsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/DiscoveredSecuritySolutionsOperations.cs @@ -87,7 +87,7 @@ internal DiscoveredSecuritySolutionsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); } } - string apiVersion = "2015-06-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -275,7 +275,7 @@ internal DiscoveredSecuritySolutionsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); } - string apiVersion = "2015-06-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -493,7 +493,7 @@ internal DiscoveredSecuritySolutionsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "discoveredSecuritySolutionName"); } - string apiVersion = "2015-06-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ExternalSecuritySolutionsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ExternalSecuritySolutionsOperations.cs index 6d64b5b99e63..436163ba715f 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ExternalSecuritySolutionsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ExternalSecuritySolutionsOperations.cs @@ -87,7 +87,7 @@ internal ExternalSecuritySolutionsOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); } } - string apiVersion = "2015-06-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -275,7 +275,7 @@ internal ExternalSecuritySolutionsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); } - string apiVersion = "2015-06-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -493,7 +493,7 @@ internal ExternalSecuritySolutionsOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "externalSecuritySolutionsName"); } - string apiVersion = "2015-06-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAdaptiveApplicationControlsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAdaptiveApplicationControlsOperations.cs index 8b2594822288..695e503a7b24 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAdaptiveApplicationControlsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAdaptiveApplicationControlsOperations.cs @@ -24,7 +24,7 @@ namespace Microsoft.Azure.Management.Security public partial interface IAdaptiveApplicationControlsOperations { /// - /// Gets a list of application control VM/server groups for the + /// Gets a list of application control machine groups for the /// subscription. /// /// @@ -48,12 +48,12 @@ public partial interface IAdaptiveApplicationControlsOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(bool? includePathRecommendations = default(bool?), bool? summary = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> ListWithHttpMessagesAsync(bool? includePathRecommendations = default(bool?), bool? summary = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Gets an application control VM/server group. /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// The headers that will be added to request. @@ -70,12 +70,12 @@ public partial interface IAdaptiveApplicationControlsOperations /// /// Thrown when a required parameter is null /// - Task> GetWithHttpMessagesAsync(string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> GetWithHttpMessagesAsync(string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Update an application control VM/server group + /// Update an application control machine group /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// @@ -94,12 +94,12 @@ public partial interface IAdaptiveApplicationControlsOperations /// /// Thrown when a required parameter is null /// - Task> PutWithHttpMessagesAsync(string groupName, AppWhitelistingGroup body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> PutWithHttpMessagesAsync(string groupName, AdaptiveApplicationControlGroup body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Delete an application control VM/server group + /// Delete an application control machine group /// /// - /// Name of an application control VM/server group + /// Name of an application control machine group /// /// /// The headers that will be added to request. diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsOperations.cs index e8e473c619fe..c494d1bdb73e 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsOperations.cs @@ -26,15 +26,6 @@ public partial interface IAlertsOperations /// /// List all the alerts that are associated with the subscription /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The headers that will be added to request. /// @@ -50,7 +41,7 @@ public partial interface IAlertsOperations /// /// Thrown when a required parameter is null /// - Task>> ListWithHttpMessagesAsync(string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// List all the alerts that are associated with the resource group /// @@ -58,15 +49,6 @@ public partial interface IAlertsOperations /// The name of the resource group within the user's subscription. The /// name is case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The headers that will be added to request. /// @@ -82,20 +64,11 @@ public partial interface IAlertsOperations /// /// Thrown when a required parameter is null /// - Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// List all the alerts that are associated with the subscription that /// are stored in a specific location /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The headers that will be added to request. /// @@ -111,7 +84,7 @@ public partial interface IAlertsOperations /// /// Thrown when a required parameter is null /// - Task>> ListSubscriptionLevelAlertsByRegionWithHttpMessagesAsync(string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListSubscriptionLevelAlertsByRegionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// List all the alerts that are associated with the resource group /// that are stored in a specific location @@ -120,15 +93,6 @@ public partial interface IAlertsOperations /// The name of the resource group within the user's subscription. The /// name is case insensitive. /// - /// - /// OData filter. Optional. - /// - /// - /// OData select. Optional. - /// - /// - /// OData expand. Optional. - /// /// /// The headers that will be added to request. /// @@ -144,7 +108,7 @@ public partial interface IAlertsOperations /// /// Thrown when a required parameter is null /// - Task>> ListResourceGroupLevelAlertsByRegionWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), string select = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListResourceGroupLevelAlertsByRegionWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Get an alert that is associated with a subscription /// @@ -231,6 +195,25 @@ public partial interface IAlertsOperations /// /// Thrown when a required parameter is null /// + Task UpdateSubscriptionLevelStateToResolveWithHttpMessagesAsync(string alertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update the alert's state + /// + /// + /// Name of the alert object + /// + /// + /// 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 UpdateSubscriptionLevelAlertStateToReactivateWithHttpMessagesAsync(string alertName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Update the alert's state @@ -254,6 +237,29 @@ public partial interface IAlertsOperations /// /// Thrown when a required parameter is null /// + Task UpdateResourceGroupLevelStateToResolveWithHttpMessagesAsync(string alertName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update the alert's state + /// + /// + /// Name of the alert object + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// 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 UpdateResourceGroupLevelAlertStateToDismissWithHttpMessagesAsync(string alertName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Update the alert's state diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsSuppressionRulesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsSuppressionRulesOperations.cs new file mode 100644 index 000000000000..41741b5ec51b --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IAlertsSuppressionRulesOperations.cs @@ -0,0 +1,138 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AlertsSuppressionRulesOperations operations. + /// + public partial interface IAlertsSuppressionRulesOperations + { + /// + /// List of all the dismiss rules for the given subscription + /// + /// + /// Type of the alert to get rules for + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string alertType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get dismiss rule, with name: {alertsSuppressionRuleName}, for the + /// given subscription + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string alertsSuppressionRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update existing rule or create new rule if it doesn't exist + /// + /// + /// The unique name of the suppression alert rule + /// + /// + /// Suppression rule object + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string alertsSuppressionRuleName, AlertsSuppressionRule alertsSuppressionRule, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete dismiss alert rule for this subscription. + /// + /// + /// The unique name of the suppression 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 alertsSuppressionRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List of all the dismiss rules for the given 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)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IConnectorsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IConnectorsOperations.cs new file mode 100644 index 000000000000..864144851048 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IConnectorsOperations.cs @@ -0,0 +1,142 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConnectorsOperations operations. + /// + public partial interface IConnectorsOperations + { + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Details of a specific cloud account connector + /// + /// + /// Name of the cloud account connector + /// + /// + /// 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 connectorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a cloud account connector or update an existing one. Connect + /// to your cloud account. For AWS, use either account credentials or + /// role-based authentication. For GCP, use account organization + /// credentials. + /// + /// + /// Name of the cloud account connector + /// + /// + /// Settings for hybrid compute management. These settings are relevant + /// only for Arc autoProvision (Hybrid Compute). + /// + /// + /// Settings for authentication management, these settings are relevant + /// only for the cloud connector. + /// + /// + /// 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 connectorName, HybridComputeSettingsProperties hybridComputeSettings = default(HybridComputeSettingsProperties), AuthenticationDetailsProperties authenticationDetails = default(AuthenticationDetailsProperties), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a cloud account connector from a subscription + /// + /// + /// Name of the cloud account connector + /// + /// + /// 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 connectorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cloud accounts connectors of a subscription + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDeviceOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDeviceOperations.cs new file mode 100644 index 000000000000..bcebea1beb02 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDeviceOperations.cs @@ -0,0 +1,52 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DeviceOperations operations. + /// + public partial interface IDeviceOperations + { + /// + /// Get device. + /// + /// + /// The identifier of the resource. + /// + /// + /// Identifier of the device. + /// + /// + /// 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 resourceId, string deviceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDevicesForHubOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDevicesForHubOperations.cs new file mode 100644 index 000000000000..42778b8f70fb --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDevicesForHubOperations.cs @@ -0,0 +1,81 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DevicesForHubOperations operations. + /// + public partial interface IDevicesForHubOperations + { + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible + /// values include: 'Managed', 'Unmanaged' + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceId, int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get list of the devices for the specified IoT Hub resource. + /// + /// + /// 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)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDevicesForSubscriptionOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDevicesForSubscriptionOperations.cs new file mode 100644 index 000000000000..71294f34df7b --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IDevicesForSubscriptionOperations.cs @@ -0,0 +1,78 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DevicesForSubscriptionOperations operations. + /// + public partial interface IDevicesForSubscriptionOperations + { + /// + /// Get list of the devices by their subscription. + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible + /// values include: 'Managed', 'Unmanaged' + /// + /// + /// 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(int? limit = default(int?), string skipToken = default(string), string deviceManagementType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get list of the devices by their 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)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotAlertTypesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotAlertTypesOperations.cs new file mode 100644 index 000000000000..bfa0d7fc1dcf --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotAlertTypesOperations.cs @@ -0,0 +1,123 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotAlertTypesOperations operations. + /// + public partial interface IIotAlertTypesOperations + { + /// + /// List IoT alert types + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT alert type + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the alert type + /// + /// + /// 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 solutionName, string iotAlertTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List IoT alert types + /// + /// + /// 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> List1WithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT alert type + /// + /// + /// Name of the alert type + /// + /// + /// 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> Get1WithHttpMessagesAsync(string iotAlertTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotAlertsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotAlertsOperations.cs new file mode 100644 index 000000000000..54ad8b08ba93 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotAlertsOperations.cs @@ -0,0 +1,217 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotAlertsOperations operations. + /// + public partial interface IIotAlertsOperations + { + /// + /// List IoT alerts + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT alert + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the alert + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string solutionName, string iotAlertId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List IoT alerts + /// + /// + /// Scope of the query: Subscription (i.e. + /// /subscriptions/{subscriptionId}) or IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible + /// values include: 'Managed', 'Unmanaged' + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// 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>> List1WithHttpMessagesAsync(string scope, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string deviceManagementType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT alert + /// + /// + /// Scope of the query: Subscription (i.e. + /// /subscriptions/{subscriptionId}) or IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the alert + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> Get1WithHttpMessagesAsync(string scope, string iotAlertId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List IoT alerts + /// + /// + /// 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 IoT alerts + /// + /// + /// 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>> List1NextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotDefenderSettingsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotDefenderSettingsOperations.cs new file mode 100644 index 000000000000..bed2a48cabac --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotDefenderSettingsOperations.cs @@ -0,0 +1,126 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotDefenderSettingsOperations operations. + /// + public partial interface IIotDefenderSettingsOperations + { + /// + /// List IoT Defender Settings + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT Defender Settings + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update IoT Defender settings + /// + /// + /// Size of the device quota (as a opposed to a Pay as You Go billing + /// model). Value is required to be in multiples of 1000. + /// + /// + /// Sentinel Workspace Resource Ids + /// + /// + /// 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(int deviceQuota, IList sentinelWorkspaceResourceIds, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete IoT Defender settings + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Information about downloadable packages + /// + /// + /// 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> PackageDownloadsMethodWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotRecommendationTypesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotRecommendationTypesOperations.cs new file mode 100644 index 000000000000..98c8d9203867 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotRecommendationTypesOperations.cs @@ -0,0 +1,123 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotRecommendationTypesOperations operations. + /// + public partial interface IIotRecommendationTypesOperations + { + /// + /// List IoT recommendation types + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT recommendation type + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the recommendation type + /// + /// + /// 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 solutionName, string iotRecommendationTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List IoT recommendation types + /// + /// + /// 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> List1WithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT recommendation type + /// + /// + /// Name of the recommendation type + /// + /// + /// 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> Get1WithHttpMessagesAsync(string iotRecommendationTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotRecommendationsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotRecommendationsOperations.cs new file mode 100644 index 000000000000..28e840a01ffa --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotRecommendationsOperations.cs @@ -0,0 +1,201 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotRecommendationsOperations operations. + /// + public partial interface IIotRecommendationsOperations + { + /// + /// List IoT recommendations + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT recommendation + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the recommendation + /// + /// + /// 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 solutionName, string iotRecommendationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List IoT recommendations + /// + /// + /// Scope of the query: Subscription (i.e. + /// /subscriptions/{subscriptionId}) or IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// 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>> List1WithHttpMessagesAsync(string scope, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT recommendation + /// + /// + /// Scope of the query: Subscription (i.e. + /// /subscriptions/{subscriptionId}) or IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the recommendation + /// + /// + /// 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> Get1WithHttpMessagesAsync(string scope, string iotRecommendationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List IoT recommendations + /// + /// + /// 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 IoT recommendations + /// + /// + /// 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>> List1NextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotSensorsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotSensorsOperations.cs new file mode 100644 index 000000000000..4af820d975d9 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IIotSensorsOperations.cs @@ -0,0 +1,152 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotSensorsOperations operations. + /// + public partial interface IIotSensorsOperations + { + /// + /// List IoT sensors + /// + /// + /// Scope of the query (IoT Hub, + /// /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get IoT sensor + /// + /// + /// Scope of the query (IoT Hub, + /// /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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 scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update IoT sensor + /// + /// + /// Scope of the query (IoT Hub, + /// /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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 scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete IoT sensor + /// + /// + /// Scope of the query (IoT Hub, + /// /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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 scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Download sensor activation file + /// + /// + /// Scope of the query (IoT Hub, + /// /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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> DownloadActivationWithHttpMessagesAsync(string scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IOnPremiseIotSensorsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IOnPremiseIotSensorsOperations.cs new file mode 100644 index 000000000000..c0a284754602 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IOnPremiseIotSensorsOperations.cs @@ -0,0 +1,132 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Threading; + using System.Threading.Tasks; + + /// + /// OnPremiseIotSensorsOperations operations. + /// + public partial interface IOnPremiseIotSensorsOperations + { + /// + /// List on-premise IoT sensors + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get on-premise IoT sensor + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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 onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update on-premise IoT sensor + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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 onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete on-premise IoT sensor + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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 onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Download sensor activation file + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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> DownloadActivationWithHttpMessagesAsync(string onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoreControlDefinitionsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoreControlDefinitionsOperations.cs new file mode 100644 index 000000000000..1d91735fd1e9 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoreControlDefinitionsOperations.cs @@ -0,0 +1,113 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecureScoreControlDefinitionsOperations operations. + /// + public partial interface ISecureScoreControlDefinitionsOperations + { + /// + /// List the available security controls, their assessments, and the + /// max score + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// For a specified subscription, list the available security controls, + /// their assessments, and the max score + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the available security controls, their assessments, and the + /// max score + /// + /// + /// 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)); + /// + /// For a specified subscription, list the available security controls, + /// their assessments, and the max score + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoreControlsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoreControlsOperations.cs new file mode 100644 index 000000000000..48f818ae653f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoreControlsOperations.cs @@ -0,0 +1,119 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecureScoreControlsOperations operations. + /// + public partial interface ISecureScoreControlsOperations + { + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' + /// as in the sample request below. + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + /// + /// 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>> ListBySecureScoreWithHttpMessagesAsync(string secureScoreName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all security controls within a scope + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// 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>> ListBySecureScoreNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all security controls within a scope + /// + /// + /// 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)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoresOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoresOperations.cs new file mode 100644 index 000000000000..4602b8234f48 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecureScoresOperations.cs @@ -0,0 +1,94 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecureScoresOperations operations. + /// + public partial interface ISecureScoresOperations + { + /// + /// List secure scores for all your Security Center initiatives within + /// your current scope. + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get secure score for a specific Security Center initiative within + /// your current scope. For the ASC Default initiative, use 'ascScore'. + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' + /// as in the sample request below. + /// + /// + /// 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 secureScoreName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List secure scores for all your Security Center initiatives within + /// your current scope. + /// + /// + /// 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)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecurityCenterClient.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecurityCenterClient.cs index dbae800cbaa5..9e8b01ad5fbd 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecurityCenterClient.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecurityCenterClient.cs @@ -81,11 +81,6 @@ public partial interface ISecurityCenterClient : System.IDisposable /// IPricingsOperations Pricings { get; } - /// - /// Gets the IAlertsOperations. - /// - IAlertsOperations Alerts { get; } - /// /// Gets the ISettingsOperations. /// @@ -122,14 +117,24 @@ public partial interface ISecurityCenterClient : System.IDisposable IIotSecuritySolutionsAnalyticsRecommendationOperations IotSecuritySolutionsAnalyticsRecommendation { get; } /// - /// Gets the IDiscoveredSecuritySolutionsOperations. + /// Gets the IIotAlertTypesOperations. /// - IDiscoveredSecuritySolutionsOperations DiscoveredSecuritySolutions { get; } + IIotAlertTypesOperations IotAlertTypes { get; } /// - /// Gets the IExternalSecuritySolutionsOperations. + /// Gets the IIotAlertsOperations. /// - IExternalSecuritySolutionsOperations ExternalSecuritySolutions { get; } + IIotAlertsOperations IotAlerts { get; } + + /// + /// Gets the IIotRecommendationTypesOperations. + /// + IIotRecommendationTypesOperations IotRecommendationTypes { get; } + + /// + /// Gets the IIotRecommendationsOperations. + /// + IIotRecommendationsOperations IotRecommendations { get; } /// /// Gets the ILocationsOperations. @@ -186,11 +191,6 @@ public partial interface ISecurityCenterClient : System.IDisposable /// IRegulatoryComplianceAssessmentsOperations RegulatoryComplianceAssessments { get; } - /// - /// Gets the IServerVulnerabilityAssessmentOperations. - /// - IServerVulnerabilityAssessmentOperations ServerVulnerabilityAssessment { get; } - /// /// Gets the ISubAssessmentsOperations. /// @@ -201,6 +201,16 @@ public partial interface ISecurityCenterClient : System.IDisposable /// IAutomationsOperations Automations { get; } + /// + /// Gets the IAlertsSuppressionRulesOperations. + /// + IAlertsSuppressionRulesOperations AlertsSuppressionRules { get; } + + /// + /// Gets the IServerVulnerabilityAssessmentOperations. + /// + IServerVulnerabilityAssessmentOperations ServerVulnerabilityAssessment { get; } + /// /// Gets the IAssessmentsMetadataOperations. /// @@ -231,10 +241,100 @@ public partial interface ISecurityCenterClient : System.IDisposable /// ITopologyOperations Topology { get; } + /// + /// Gets the IAlertsOperations. + /// + IAlertsOperations Alerts { get; } + /// /// Gets the IJitNetworkAccessPoliciesOperations. /// IJitNetworkAccessPoliciesOperations JitNetworkAccessPolicies { get; } + /// + /// Gets the IDiscoveredSecuritySolutionsOperations. + /// + IDiscoveredSecuritySolutionsOperations DiscoveredSecuritySolutions { get; } + + /// + /// Gets the ISecuritySolutionsReferenceDataOperations. + /// + ISecuritySolutionsReferenceDataOperations SecuritySolutionsReferenceData { get; } + + /// + /// Gets the IExternalSecuritySolutionsOperations. + /// + IExternalSecuritySolutionsOperations ExternalSecuritySolutions { get; } + + /// + /// Gets the ISecureScoresOperations. + /// + ISecureScoresOperations SecureScores { get; } + + /// + /// Gets the ISecureScoreControlsOperations. + /// + ISecureScoreControlsOperations SecureScoreControls { get; } + + /// + /// Gets the ISecureScoreControlDefinitionsOperations. + /// + ISecureScoreControlDefinitionsOperations SecureScoreControlDefinitions { get; } + + /// + /// Gets the ISecuritySolutionsOperations. + /// + ISecuritySolutionsOperations SecuritySolutions { get; } + + /// + /// Gets the IConnectorsOperations. + /// + IConnectorsOperations Connectors { get; } + + /// + /// Gets the ISqlVulnerabilityAssessmentScansOperations. + /// + ISqlVulnerabilityAssessmentScansOperations SqlVulnerabilityAssessmentScans { get; } + + /// + /// Gets the ISqlVulnerabilityAssessmentScanResultsOperations. + /// + ISqlVulnerabilityAssessmentScanResultsOperations SqlVulnerabilityAssessmentScanResults { get; } + + /// + /// Gets the ISqlVulnerabilityAssessmentBaselineRulesOperations. + /// + ISqlVulnerabilityAssessmentBaselineRulesOperations SqlVulnerabilityAssessmentBaselineRules { get; } + + /// + /// Gets the IIotDefenderSettingsOperations. + /// + IIotDefenderSettingsOperations IotDefenderSettings { get; } + + /// + /// Gets the IIotSensorsOperations. + /// + IIotSensorsOperations IotSensors { get; } + + /// + /// Gets the IDevicesForSubscriptionOperations. + /// + IDevicesForSubscriptionOperations DevicesForSubscription { get; } + + /// + /// Gets the IDevicesForHubOperations. + /// + IDevicesForHubOperations DevicesForHub { get; } + + /// + /// Gets the IDeviceOperations. + /// + IDeviceOperations Device { get; } + + /// + /// Gets the IOnPremiseIotSensorsOperations. + /// + IOnPremiseIotSensorsOperations OnPremiseIotSensors { get; } + } } diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecuritySolutionsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecuritySolutionsOperations.cs new file mode 100644 index 000000000000..e59e818e3dc7 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecuritySolutionsOperations.cs @@ -0,0 +1,94 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecuritySolutionsOperations operations. + /// + public partial interface ISecuritySolutionsOperations + { + /// + /// Gets a list of Security Solutions for the subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a specific Security Solution. + /// + /// + /// The name of the resource group within the user's subscription. The + /// name is case insensitive. + /// + /// + /// Name of security solution. + /// + /// + /// 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 securitySolutionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of Security Solutions for 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)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecuritySolutionsReferenceDataOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecuritySolutionsReferenceDataOperations.cs new file mode 100644 index 000000000000..0d8b4e9c13ef --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISecuritySolutionsReferenceDataOperations.cs @@ -0,0 +1,67 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecuritySolutionsReferenceDataOperations operations. + /// + public partial interface ISecuritySolutionsReferenceDataOperations + { + /// + /// Gets a list of all supported Security Solutions for the + /// subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets list of all supported Security Solutions for subscription and + /// location. + /// + /// + /// 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> ListByHomeRegionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentBaselineRulesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentBaselineRulesOperations.cs new file mode 100644 index 000000000000..f0ee5c0b7086 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentBaselineRulesOperations.cs @@ -0,0 +1,189 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlVulnerabilityAssessmentBaselineRulesOperations operations. + /// + public partial interface ISqlVulnerabilityAssessmentBaselineRulesOperations + { + /// + /// Creates a Baseline for a rule in a database. Will overwrite any + /// previously existing results. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + /// + /// 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 ruleId, string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IList> results = default(IList>), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the results for a given rule in the Baseline. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 ruleId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a rule from the Baseline of a given database. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 ruleId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the results for all rules in the Baseline. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Add a list of baseline rules. Will overwrite any previously + /// existing results (for all rules). + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + /// + /// 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> AddWithHttpMessagesAsync(string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IDictionary>> results = default(IDictionary>>), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentScanResultsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentScanResultsOperations.cs new file mode 100644 index 000000000000..57f3455ec59f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentScanResultsOperations.cs @@ -0,0 +1,94 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlVulnerabilityAssessmentScanResultsOperations operations. + /// + public partial interface ISqlVulnerabilityAssessmentScanResultsOperations + { + /// + /// Gets the scan results of a single rule in a scan record. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest + /// scan. + /// + /// + /// The rule Id of the results. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 scanId, string scanResultId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of scan results for a single scan record. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest + /// scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string scanId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentScansOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentScansOperations.cs new file mode 100644 index 000000000000..f8e610d3c62e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ISqlVulnerabilityAssessmentScansOperations.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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlVulnerabilityAssessmentScansOperations operations. + /// + public partial interface ISqlVulnerabilityAssessmentScansOperations + { + /// + /// Gets the scan details of a single scan record. + /// + /// + /// The scan Id. Type 'latest' to get the scan record for the latest + /// scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 scanId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of scan records. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/InformationProtectionPoliciesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/InformationProtectionPoliciesOperations.cs index 304398e4e426..b0dd1523134d 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/InformationProtectionPoliciesOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/InformationProtectionPoliciesOperations.cs @@ -110,7 +110,7 @@ internal InformationProtectionPoliciesOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); _url = _url.Replace("{informationProtectionPolicyName}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(informationProtectionPolicyName, Client.SerializationSettings).Trim('"'))); List _queryParameters = new List(); if (apiVersion != null) @@ -315,7 +315,7 @@ internal InformationProtectionPoliciesOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); _url = _url.Replace("{informationProtectionPolicyName}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(informationProtectionPolicyName, Client.SerializationSettings).Trim('"'))); List _queryParameters = new List(); if (apiVersion != null) @@ -522,7 +522,7 @@ internal InformationProtectionPoliciesOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/informationProtectionPolicies").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); List _queryParameters = new List(); if (apiVersion != null) { diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertTypesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertTypesOperations.cs new file mode 100644 index 000000000000..61c52ef08a17 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertTypesOperations.cs @@ -0,0 +1,872 @@ +// +// 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.Security +{ + 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; + + /// + /// IotAlertTypesOperations operations. + /// + internal partial class IotAlertTypesOperations : IServiceOperations, IIotAlertTypesOperations + { + /// + /// Initializes a new instance of the IotAlertTypesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotAlertTypesOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List IoT alert types + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotAlertTypes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT alert type + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the alert type + /// + /// + /// 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 solutionName, string iotAlertTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + if (iotAlertTypeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotAlertTypeName"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("iotAlertTypeName", iotAlertTypeName); + 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.Security/iotSecuritySolutions/{solutionName}/iotAlertTypes/{iotAlertTypeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + _url = _url.Replace("{iotAlertTypeName}", System.Uri.EscapeDataString(iotAlertTypeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT alert types + /// + /// + /// 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> List1WithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotAlertTypes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT alert type + /// + /// + /// Name of the alert type + /// + /// + /// 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> Get1WithHttpMessagesAsync(string iotAlertTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (iotAlertTypeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotAlertTypeName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("iotAlertTypeName", iotAlertTypeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotAlertTypes/{iotAlertTypeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{iotAlertTypeName}", System.Uri.EscapeDataString(iotAlertTypeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertTypesOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertTypesOperationsExtensions.cs new file mode 100644 index 000000000000..8ee11c95c0f7 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertTypesOperationsExtensions.cs @@ -0,0 +1,177 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for IotAlertTypesOperations. + /// + public static partial class IotAlertTypesOperationsExtensions + { + /// + /// List IoT alert types + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + public static IotAlertTypeList List(this IIotAlertTypesOperations operations, string resourceGroupName, string solutionName) + { + return operations.ListAsync(resourceGroupName, solutionName).GetAwaiter().GetResult(); + } + + /// + /// List IoT alert types + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IIotAlertTypesOperations operations, string resourceGroupName, string solutionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, solutionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT alert type + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the alert type + /// + public static IotAlertType Get(this IIotAlertTypesOperations operations, string resourceGroupName, string solutionName, string iotAlertTypeName) + { + return operations.GetAsync(resourceGroupName, solutionName, iotAlertTypeName).GetAwaiter().GetResult(); + } + + /// + /// Get IoT alert type + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the alert type + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotAlertTypesOperations operations, string resourceGroupName, string solutionName, string iotAlertTypeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, solutionName, iotAlertTypeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT alert types + /// + /// + /// The operations group for this extension method. + /// + public static IotAlertTypeList List1(this IIotAlertTypesOperations operations) + { + return operations.List1Async().GetAwaiter().GetResult(); + } + + /// + /// List IoT alert types + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task List1Async(this IIotAlertTypesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.List1WithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT alert type + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the alert type + /// + public static IotAlertType Get1(this IIotAlertTypesOperations operations, string iotAlertTypeName) + { + return operations.Get1Async(iotAlertTypeName).GetAwaiter().GetResult(); + } + + /// + /// Get IoT alert type + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the alert type + /// + /// + /// The cancellation token. + /// + public static async Task Get1Async(this IIotAlertTypesOperations operations, string iotAlertTypeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.Get1WithHttpMessagesAsync(iotAlertTypeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertsOperations.cs new file mode 100644 index 000000000000..27dff89706fd --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertsOperations.cs @@ -0,0 +1,1321 @@ +// +// 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.Security +{ + 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; + + /// + /// IotAlertsOperations operations. + /// + internal partial class IotAlertsOperations : IServiceOperations, IIotAlertsOperations + { + /// + /// Initializes a new instance of the IotAlertsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotAlertsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List IoT alerts + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("minStartTimeUtc", minStartTimeUtc); + tracingParameters.Add("maxStartTimeUtc", maxStartTimeUtc); + tracingParameters.Add("alertType", alertType); + tracingParameters.Add("compromisedEntity", compromisedEntity); + tracingParameters.Add("limit", limit); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotAlerts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (minStartTimeUtc != null) + { + _queryParameters.Add(string.Format("startTimeUtc>={0}", System.Uri.EscapeDataString(minStartTimeUtc))); + } + if (maxStartTimeUtc != null) + { + _queryParameters.Add(string.Format("startTimeUtc<={0}", System.Uri.EscapeDataString(maxStartTimeUtc))); + } + if (alertType != null) + { + _queryParameters.Add(string.Format("alertType={0}", System.Uri.EscapeDataString(alertType))); + } + if (compromisedEntity != null) + { + _queryParameters.Add(string.Format("compromisedEntity={0}", System.Uri.EscapeDataString(compromisedEntity))); + } + if (limit != null) + { + _queryParameters.Add(string.Format("$limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT alert + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the alert + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string solutionName, string iotAlertId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + if (iotAlertId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotAlertId"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("iotAlertId", iotAlertId); + 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.Security/iotSecuritySolutions/{solutionName}/iotAlerts/{iotAlertId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + _url = _url.Replace("{iotAlertId}", System.Uri.EscapeDataString(iotAlertId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT alerts + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// 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>> List1WithHttpMessagesAsync(string scope, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string deviceManagementType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("minStartTimeUtc", minStartTimeUtc); + tracingParameters.Add("maxStartTimeUtc", maxStartTimeUtc); + tracingParameters.Add("alertType", alertType); + tracingParameters.Add("deviceManagementType", deviceManagementType); + tracingParameters.Add("compromisedEntity", compromisedEntity); + tracingParameters.Add("limit", limit); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotAlerts").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (minStartTimeUtc != null) + { + _queryParameters.Add(string.Format("startTimeUtc>={0}", System.Uri.EscapeDataString(minStartTimeUtc))); + } + if (maxStartTimeUtc != null) + { + _queryParameters.Add(string.Format("startTimeUtc<={0}", System.Uri.EscapeDataString(maxStartTimeUtc))); + } + if (alertType != null) + { + _queryParameters.Add(string.Format("alertType={0}", System.Uri.EscapeDataString(alertType))); + } + if (deviceManagementType != null) + { + _queryParameters.Add(string.Format("deviceManagementType={0}", System.Uri.EscapeDataString(deviceManagementType))); + } + if (compromisedEntity != null) + { + _queryParameters.Add(string.Format("compromisedEntity={0}", System.Uri.EscapeDataString(compromisedEntity))); + } + if (limit != null) + { + _queryParameters.Add(string.Format("$limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT alert + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the alert + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> Get1WithHttpMessagesAsync(string scope, string iotAlertId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (iotAlertId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotAlertId"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("iotAlertId", iotAlertId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotAlerts/{iotAlertId}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{iotAlertId}", System.Uri.EscapeDataString(iotAlertId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT alerts + /// + /// + /// 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT alerts + /// + /// + /// 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>> List1NextWithHttpMessagesAsync(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, "List1Next", 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertsOperationsExtensions.cs new file mode 100644 index 000000000000..7228b17649ab --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotAlertsOperationsExtensions.cs @@ -0,0 +1,345 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for IotAlertsOperations. + /// + public static partial class IotAlertsOperationsExtensions + { + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + public static IPage List(this IIotAlertsOperations operations, string resourceGroupName, string solutionName, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, solutionName, minStartTimeUtc, maxStartTimeUtc, alertType, compromisedEntity, limit, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IIotAlertsOperations operations, string resourceGroupName, string solutionName, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, solutionName, minStartTimeUtc, maxStartTimeUtc, alertType, compromisedEntity, limit, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT alert + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the alert + /// + public static IotAlert Get(this IIotAlertsOperations operations, string resourceGroupName, string solutionName, string iotAlertId) + { + return operations.GetAsync(resourceGroupName, solutionName, iotAlertId).GetAwaiter().GetResult(); + } + + /// + /// Get IoT alert + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the alert + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotAlertsOperations operations, string resourceGroupName, string solutionName, string iotAlertId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, solutionName, iotAlertId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + public static IPage List1(this IIotAlertsOperations operations, string scope, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string deviceManagementType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string)) + { + return operations.List1Async(scope, minStartTimeUtc, maxStartTimeUtc, alertType, deviceManagementType, compromisedEntity, limit, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by minimum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by maximum startTimeUtc (ISO 8601 format) + /// + /// + /// Filter by alert type + /// + /// + /// Get devices only from specific type, Managed or Unmanaged. Possible values + /// include: 'Managed', 'Unmanaged' + /// + /// + /// Filter by compromised device + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// The cancellation token. + /// + public static async Task> List1Async(this IIotAlertsOperations operations, string scope, string minStartTimeUtc = default(string), string maxStartTimeUtc = default(string), string alertType = default(string), string deviceManagementType = default(string), string compromisedEntity = default(string), int? limit = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.List1WithHttpMessagesAsync(scope, minStartTimeUtc, maxStartTimeUtc, alertType, deviceManagementType, compromisedEntity, limit, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT alert + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the alert + /// + public static IotAlertModel Get1(this IIotAlertsOperations operations, string scope, string iotAlertId) + { + return operations.Get1Async(scope, iotAlertId).GetAwaiter().GetResult(); + } + + /// + /// Get IoT alert + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the alert + /// + /// + /// The cancellation token. + /// + public static async Task Get1Async(this IIotAlertsOperations operations, string scope, string iotAlertId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.Get1WithHttpMessagesAsync(scope, iotAlertId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IIotAlertsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List IoT alerts + /// + /// + /// 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 IIotAlertsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage List1Next(this IIotAlertsOperations operations, string nextPageLink) + { + return operations.List1NextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List IoT alerts + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> List1NextAsync(this IIotAlertsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.List1NextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotDefenderSettingsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotDefenderSettingsOperations.cs new file mode 100644 index 000000000000..40ddad2dc077 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotDefenderSettingsOperations.cs @@ -0,0 +1,994 @@ +// +// 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.Security +{ + 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; + + /// + /// IotDefenderSettingsOperations operations. + /// + internal partial class IotDefenderSettingsOperations : IServiceOperations, IIotDefenderSettingsOperations + { + /// + /// Initializes a new instance of the IotDefenderSettingsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotDefenderSettingsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List IoT Defender Settings + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotDefenderSettings").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT Defender Settings + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotDefenderSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update IoT Defender settings + /// + /// + /// Size of the device quota (as a opposed to a Pay as You Go billing model). + /// Value is required to be in multiples of 1000. + /// + /// + /// Sentinel Workspace Resource Ids + /// + /// + /// 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(int deviceQuota, IList sentinelWorkspaceResourceIds, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (deviceQuota < 1000) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "deviceQuota", 1000); + } + if (sentinelWorkspaceResourceIds == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "sentinelWorkspaceResourceIds"); + } + string apiVersion = "2020-08-06-preview"; + IotDefenderSettingsModel iotDefenderSettingsModel = new IotDefenderSettingsModel(); + if (sentinelWorkspaceResourceIds != null) + { + iotDefenderSettingsModel.DeviceQuota = deviceQuota; + iotDefenderSettingsModel.SentinelWorkspaceResourceIds = sentinelWorkspaceResourceIds; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("iotDefenderSettingsModel", iotDefenderSettingsModel); + 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}/providers/Microsoft.Security/iotDefenderSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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(iotDefenderSettingsModel != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(iotDefenderSettingsModel, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete IoT Defender settings + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotDefenderSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Information about downloadable packages + /// + /// + /// 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> PackageDownloadsMethodWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "PackageDownloadsMethod", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotDefenderSettings/default/packageDownloads").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotDefenderSettingsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotDefenderSettingsOperationsExtensions.cs new file mode 100644 index 000000000000..caddc0e95049 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotDefenderSettingsOperationsExtensions.cs @@ -0,0 +1,178 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for IotDefenderSettingsOperations. + /// + public static partial class IotDefenderSettingsOperationsExtensions + { + /// + /// List IoT Defender Settings + /// + /// + /// The operations group for this extension method. + /// + public static IotDefenderSettingsList List(this IIotDefenderSettingsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List IoT Defender Settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IIotDefenderSettingsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT Defender Settings + /// + /// + /// The operations group for this extension method. + /// + public static IotDefenderSettingsModel Get(this IIotDefenderSettingsOperations operations) + { + return operations.GetAsync().GetAwaiter().GetResult(); + } + + /// + /// Get IoT Defender Settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotDefenderSettingsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update IoT Defender settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// Size of the device quota (as a opposed to a Pay as You Go billing model). + /// Value is required to be in multiples of 1000. + /// + /// + /// Sentinel Workspace Resource Ids + /// + public static IotDefenderSettingsModel CreateOrUpdate(this IIotDefenderSettingsOperations operations, int deviceQuota, IList sentinelWorkspaceResourceIds) + { + return operations.CreateOrUpdateAsync(deviceQuota, sentinelWorkspaceResourceIds).GetAwaiter().GetResult(); + } + + /// + /// Create or update IoT Defender settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// Size of the device quota (as a opposed to a Pay as You Go billing model). + /// Value is required to be in multiples of 1000. + /// + /// + /// Sentinel Workspace Resource Ids + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IIotDefenderSettingsOperations operations, int deviceQuota, IList sentinelWorkspaceResourceIds, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(deviceQuota, sentinelWorkspaceResourceIds, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete IoT Defender settings + /// + /// + /// The operations group for this extension method. + /// + public static void Delete(this IIotDefenderSettingsOperations operations) + { + operations.DeleteAsync().GetAwaiter().GetResult(); + } + + /// + /// Delete IoT Defender settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IIotDefenderSettingsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Information about downloadable packages + /// + /// + /// The operations group for this extension method. + /// + public static PackageDownloads PackageDownloadsMethod(this IIotDefenderSettingsOperations operations) + { + return operations.PackageDownloadsMethodAsync().GetAwaiter().GetResult(); + } + + /// + /// Information about downloadable packages + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task PackageDownloadsMethodAsync(this IIotDefenderSettingsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PackageDownloadsMethodWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationTypesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationTypesOperations.cs new file mode 100644 index 000000000000..12d98eff4a18 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationTypesOperations.cs @@ -0,0 +1,872 @@ +// +// 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.Security +{ + 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; + + /// + /// IotRecommendationTypesOperations operations. + /// + internal partial class IotRecommendationTypesOperations : IServiceOperations, IIotRecommendationTypesOperations + { + /// + /// Initializes a new instance of the IotRecommendationTypesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotRecommendationTypesOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List IoT recommendation types + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotRecommendationTypes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT recommendation type + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the recommendation type + /// + /// + /// 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 solutionName, string iotRecommendationTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + if (iotRecommendationTypeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotRecommendationTypeName"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("iotRecommendationTypeName", iotRecommendationTypeName); + 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.Security/iotSecuritySolutions/{solutionName}/iotRecommendationTypes/{iotRecommendationTypeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + _url = _url.Replace("{iotRecommendationTypeName}", System.Uri.EscapeDataString(iotRecommendationTypeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT recommendation types + /// + /// + /// 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> List1WithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotRecommendationTypes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT recommendation type + /// + /// + /// Name of the recommendation type + /// + /// + /// 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> Get1WithHttpMessagesAsync(string iotRecommendationTypeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (iotRecommendationTypeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotRecommendationTypeName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("iotRecommendationTypeName", iotRecommendationTypeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/iotRecommendationTypes/{iotRecommendationTypeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{iotRecommendationTypeName}", System.Uri.EscapeDataString(iotRecommendationTypeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationTypesOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationTypesOperationsExtensions.cs new file mode 100644 index 000000000000..dfccadbecb6c --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationTypesOperationsExtensions.cs @@ -0,0 +1,177 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for IotRecommendationTypesOperations. + /// + public static partial class IotRecommendationTypesOperationsExtensions + { + /// + /// List IoT recommendation types + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + public static IotRecommendationTypeList List(this IIotRecommendationTypesOperations operations, string resourceGroupName, string solutionName) + { + return operations.ListAsync(resourceGroupName, solutionName).GetAwaiter().GetResult(); + } + + /// + /// List IoT recommendation types + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IIotRecommendationTypesOperations operations, string resourceGroupName, string solutionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, solutionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT recommendation type + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the recommendation type + /// + public static IotRecommendationType Get(this IIotRecommendationTypesOperations operations, string resourceGroupName, string solutionName, string iotRecommendationTypeName) + { + return operations.GetAsync(resourceGroupName, solutionName, iotRecommendationTypeName).GetAwaiter().GetResult(); + } + + /// + /// Get IoT recommendation type + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Name of the recommendation type + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotRecommendationTypesOperations operations, string resourceGroupName, string solutionName, string iotRecommendationTypeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, solutionName, iotRecommendationTypeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT recommendation types + /// + /// + /// The operations group for this extension method. + /// + public static IotRecommendationTypeList List1(this IIotRecommendationTypesOperations operations) + { + return operations.List1Async().GetAwaiter().GetResult(); + } + + /// + /// List IoT recommendation types + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task List1Async(this IIotRecommendationTypesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.List1WithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT recommendation type + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the recommendation type + /// + public static IotRecommendationType Get1(this IIotRecommendationTypesOperations operations, string iotRecommendationTypeName) + { + return operations.Get1Async(iotRecommendationTypeName).GetAwaiter().GetResult(); + } + + /// + /// Get IoT recommendation type + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the recommendation type + /// + /// + /// The cancellation token. + /// + public static async Task Get1Async(this IIotRecommendationTypesOperations operations, string iotRecommendationTypeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.Get1WithHttpMessagesAsync(iotRecommendationTypeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationsOperations.cs new file mode 100644 index 000000000000..2d77cef2d004 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationsOperations.cs @@ -0,0 +1,1280 @@ +// +// 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.Security +{ + 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; + + /// + /// IotRecommendationsOperations operations. + /// + internal partial class IotRecommendationsOperations : IServiceOperations, IIotRecommendationsOperations + { + /// + /// Initializes a new instance of the IotRecommendationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotRecommendationsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List IoT recommendations + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string solutionName, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("recommendationType", recommendationType); + tracingParameters.Add("deviceId", deviceId); + tracingParameters.Add("limit", limit); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotRecommendations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (recommendationType != null) + { + _queryParameters.Add(string.Format("recommendationType={0}", System.Uri.EscapeDataString(recommendationType))); + } + if (deviceId != null) + { + _queryParameters.Add(string.Format("deviceId={0}", System.Uri.EscapeDataString(deviceId))); + } + if (limit != null) + { + _queryParameters.Add(string.Format("$limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT recommendation + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the recommendation + /// + /// + /// 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 solutionName, string iotRecommendationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (solutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "solutionName"); + } + if (iotRecommendationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotRecommendationId"); + } + string apiVersion = "2019-08-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("resourceGroupName", resourceGroupName); + tracingParameters.Add("solutionName", solutionName); + tracingParameters.Add("iotRecommendationId", iotRecommendationId); + 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.Security/iotSecuritySolutions/{solutionName}/iotRecommendations/{iotRecommendationId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{solutionName}", System.Uri.EscapeDataString(solutionName)); + _url = _url.Replace("{iotRecommendationId}", System.Uri.EscapeDataString(iotRecommendationId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT recommendations + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// 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>> List1WithHttpMessagesAsync(string scope, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("recommendationType", recommendationType); + tracingParameters.Add("deviceId", deviceId); + tracingParameters.Add("limit", limit); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotRecommendations").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (recommendationType != null) + { + _queryParameters.Add(string.Format("recommendationType={0}", System.Uri.EscapeDataString(recommendationType))); + } + if (deviceId != null) + { + _queryParameters.Add(string.Format("deviceId={0}", System.Uri.EscapeDataString(deviceId))); + } + if (limit != null) + { + _queryParameters.Add(string.Format("$limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(limit, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT recommendation + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the recommendation + /// + /// + /// 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> Get1WithHttpMessagesAsync(string scope, string iotRecommendationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (iotRecommendationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotRecommendationId"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("iotRecommendationId", iotRecommendationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get1", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotRecommendations/{iotRecommendationId}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{iotRecommendationId}", System.Uri.EscapeDataString(iotRecommendationId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT recommendations + /// + /// + /// 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List IoT recommendations + /// + /// + /// 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>> List1NextWithHttpMessagesAsync(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, "List1Next", 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationsOperationsExtensions.cs new file mode 100644 index 000000000000..c55262edd327 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotRecommendationsOperationsExtensions.cs @@ -0,0 +1,313 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for IotRecommendationsOperations. + /// + public static partial class IotRecommendationsOperationsExtensions + { + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + public static IPage List(this IIotRecommendationsOperations operations, string resourceGroupName, string solutionName, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, solutionName, recommendationType, deviceId, limit, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IIotRecommendationsOperations operations, string resourceGroupName, string solutionName, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, solutionName, recommendationType, deviceId, limit, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT recommendation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the recommendation + /// + public static IotRecommendation Get(this IIotRecommendationsOperations operations, string resourceGroupName, string solutionName, string iotRecommendationId) + { + return operations.GetAsync(resourceGroupName, solutionName, iotRecommendationId).GetAwaiter().GetResult(); + } + + /// + /// Get IoT recommendation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// The name of the IoT Security solution. + /// + /// + /// Id of the recommendation + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotRecommendationsOperations operations, string resourceGroupName, string solutionName, string iotRecommendationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, solutionName, iotRecommendationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + public static IPage List1(this IIotRecommendationsOperations operations, string scope, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string)) + { + return operations.List1Async(scope, recommendationType, deviceId, limit, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Filter by recommendation type + /// + /// + /// Filter by device id + /// + /// + /// Limit the number of items returned in a single page + /// + /// + /// Skip token used for pagination + /// + /// + /// The cancellation token. + /// + public static async Task> List1Async(this IIotRecommendationsOperations operations, string scope, string recommendationType = default(string), string deviceId = default(string), int? limit = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.List1WithHttpMessagesAsync(scope, recommendationType, deviceId, limit, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT recommendation + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the recommendation + /// + public static IotRecommendationModel Get1(this IIotRecommendationsOperations operations, string scope, string iotRecommendationId) + { + return operations.Get1Async(scope, iotRecommendationId).GetAwaiter().GetResult(); + } + + /// + /// Get IoT recommendation + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query: Subscription (i.e. /subscriptions/{subscriptionId}) or + /// IoT Hub (i.e. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Devices/iotHubs/{iotHubName}) + /// + /// + /// Id of the recommendation + /// + /// + /// The cancellation token. + /// + public static async Task Get1Async(this IIotRecommendationsOperations operations, string scope, string iotRecommendationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.Get1WithHttpMessagesAsync(scope, iotRecommendationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IIotRecommendationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List IoT recommendations + /// + /// + /// 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 IIotRecommendationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage List1Next(this IIotRecommendationsOperations operations, string nextPageLink) + { + return operations.List1NextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List IoT recommendations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> List1NextAsync(this IIotRecommendationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.List1NextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotSensorsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotSensorsOperations.cs new file mode 100644 index 000000000000..45873dc507b1 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotSensorsOperations.cs @@ -0,0 +1,975 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotSensorsOperations operations. + /// + internal partial class IotSensorsOperations : IServiceOperations, IIotSensorsOperations + { + /// + /// Initializes a new instance of the IotSensorsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotSensorsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List IoT sensors + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotSensors").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get IoT sensor + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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 scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (iotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("iotSensorName", iotSensorName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotSensors/{iotSensorName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{iotSensorName}", System.Uri.EscapeDataString(iotSensorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update IoT sensor + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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 scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (iotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("iotSensorName", iotSensorName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotSensors/{iotSensorName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{iotSensorName}", System.Uri.EscapeDataString(iotSensorName)); + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete IoT sensor + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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 scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (iotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("iotSensorName", iotSensorName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotSensors/{iotSensorName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{iotSensorName}", System.Uri.EscapeDataString(iotSensorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Download sensor activation file + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// 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> DownloadActivationWithHttpMessagesAsync(string scope, string iotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (iotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scope", scope); + tracingParameters.Add("iotSensorName", iotSensorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DownloadActivation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/iotSensors/{iotSensorName}/downloadActivation").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{iotSensorName}", System.Uri.EscapeDataString(iotSensorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotSensorsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotSensorsOperationsExtensions.cs new file mode 100644 index 000000000000..c5d3a27e2f22 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/IotSensorsOperationsExtensions.cs @@ -0,0 +1,216 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.IO; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for IotSensorsOperations. + /// + public static partial class IotSensorsOperationsExtensions + { + /// + /// List IoT sensors + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + public static IotSensorsList List(this IIotSensorsOperations operations, string scope) + { + return operations.ListAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// List IoT sensors + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IIotSensorsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + public static IotSensor Get(this IIotSensorsOperations operations, string scope, string iotSensorName) + { + return operations.GetAsync(scope, iotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Get IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotSensorsOperations operations, string scope, string iotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, iotSensorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + public static IotSensor CreateOrUpdate(this IIotSensorsOperations operations, string scope, string iotSensorName) + { + return operations.CreateOrUpdateAsync(scope, iotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Create or update IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IIotSensorsOperations operations, string scope, string iotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(scope, iotSensorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + public static void Delete(this IIotSensorsOperations operations, string scope, string iotSensorName) + { + operations.DeleteAsync(scope, iotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Delete IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IIotSensorsOperations operations, string scope, string iotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(scope, iotSensorName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Download sensor activation file + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + public static Stream DownloadActivation(this IIotSensorsOperations operations, string scope, string iotSensorName) + { + return operations.DownloadActivationAsync(scope, iotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Download sensor activation file + /// + /// + /// The operations group for this extension method. + /// + /// + /// Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) + /// + /// + /// Name of the IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task DownloadActivationAsync(this IIotSensorsOperations operations, string scope, string iotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + var _result = await operations.DownloadActivationWithHttpMessagesAsync(scope, iotSensorName, null, cancellationToken).ConfigureAwait(false); + _result.Request.Dispose(); + return _result.Body; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlGroup.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlGroup.cs new file mode 100644 index 000000000000..584a79c8d071 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlGroup.cs @@ -0,0 +1,145 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + [Rest.Serialization.JsonTransformation] + public partial class AdaptiveApplicationControlGroup + { + /// + /// Initializes a new instance of the AdaptiveApplicationControlGroup + /// class. + /// + public AdaptiveApplicationControlGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AdaptiveApplicationControlGroup + /// class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// Location where the resource is + /// stored + /// Possible values include: 'Audit', + /// 'Enforce', 'None' + /// Possible values include: + /// 'Configured', 'NotConfigured', 'InProgress', 'Failed', + /// 'NoStatus' + /// Possible values include: + /// 'Recommended', 'NotRecommended', 'NotAvailable', 'NoStatus' + /// Possible values include: + /// 'Azure_AppLocker', 'Azure_AuditD', 'NonAzure_AppLocker', + /// 'NonAzure_AuditD', 'None' + public AdaptiveApplicationControlGroup(string id = default(string), string name = default(string), string type = default(string), string location = default(string), string enforcementMode = default(string), ProtectionMode protectionMode = default(ProtectionMode), string configurationStatus = default(string), string recommendationStatus = default(string), IList issues = default(IList), string sourceSystem = default(string), IList vmRecommendations = default(IList), IList pathRecommendations = default(IList)) + { + Id = id; + Name = name; + Type = type; + Location = location; + EnforcementMode = enforcementMode; + ProtectionMode = protectionMode; + ConfigurationStatus = configurationStatus; + RecommendationStatus = recommendationStatus; + Issues = issues; + SourceSystem = sourceSystem; + VmRecommendations = vmRecommendations; + PathRecommendations = pathRecommendations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets location where the resource is stored + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets or sets possible values include: 'Audit', 'Enforce', 'None' + /// + [JsonProperty(PropertyName = "properties.enforcementMode")] + public string EnforcementMode { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.protectionMode")] + public ProtectionMode ProtectionMode { get; set; } + + /// + /// Gets possible values include: 'Configured', 'NotConfigured', + /// 'InProgress', 'Failed', 'NoStatus' + /// + [JsonProperty(PropertyName = "properties.configurationStatus")] + public string ConfigurationStatus { get; private set; } + + /// + /// Gets possible values include: 'Recommended', 'NotRecommended', + /// 'NotAvailable', 'NoStatus' + /// + [JsonProperty(PropertyName = "properties.recommendationStatus")] + public string RecommendationStatus { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties.issues")] + public IList Issues { get; private set; } + + /// + /// Gets possible values include: 'Azure_AppLocker', 'Azure_AuditD', + /// 'NonAzure_AppLocker', 'NonAzure_AuditD', 'None' + /// + [JsonProperty(PropertyName = "properties.sourceSystem")] + public string SourceSystem { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties.vmRecommendations")] + public IList VmRecommendations { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.pathRecommendations")] + public IList PathRecommendations { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlGroups.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlGroups.cs new file mode 100644 index 000000000000..515e95b7c5c8 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlGroups.cs @@ -0,0 +1,54 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a list of machine groups and set of rules that are + /// recommended by Azure Security Center to be allowed + /// + public partial class AdaptiveApplicationControlGroups + { + /// + /// Initializes a new instance of the AdaptiveApplicationControlGroups + /// class. + /// + public AdaptiveApplicationControlGroups() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AdaptiveApplicationControlGroups + /// class. + /// + public AdaptiveApplicationControlGroups(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlIssueSummary.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlIssueSummary.cs new file mode 100644 index 000000000000..b97d7f1986d7 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdaptiveApplicationControlIssueSummary.cs @@ -0,0 +1,69 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a summary of the alerts of the machine group + /// + public partial class AdaptiveApplicationControlIssueSummary + { + /// + /// Initializes a new instance of the + /// AdaptiveApplicationControlIssueSummary class. + /// + public AdaptiveApplicationControlIssueSummary() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// AdaptiveApplicationControlIssueSummary class. + /// + /// Possible values include: 'ViolationsAudited', + /// 'ViolationsBlocked', 'MsiAndScriptViolationsAudited', + /// 'MsiAndScriptViolationsBlocked', 'ExecutableViolationsAudited', + /// 'RulesViolatedManually' + /// The number of machines in the group that + /// have this alert + public AdaptiveApplicationControlIssueSummary(string issue = default(string), double? numberOfVms = default(double?)) + { + Issue = issue; + NumberOfVms = numberOfVms; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'ViolationsAudited', + /// 'ViolationsBlocked', 'MsiAndScriptViolationsAudited', + /// 'MsiAndScriptViolationsBlocked', 'ExecutableViolationsAudited', + /// 'RulesViolatedManually' + /// + [JsonProperty(PropertyName = "issue")] + public string Issue { get; set; } + + /// + /// Gets or sets the number of machines in the group that have this + /// alert + /// + [JsonProperty(PropertyName = "numberOfVms")] + public double? NumberOfVms { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdditionalData.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdditionalData.cs index efcb3ced1b86..a052f822516a 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdditionalData.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AdditionalData.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Details of the sub-assessment /// - [Newtonsoft.Json.JsonObject("AdditionalData")] public partial class AdditionalData { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Alert.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Alert.cs index c35ea493d428..5fb148c23aa4 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Alert.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Alert.cs @@ -37,76 +37,93 @@ public Alert() /// Resource Id /// Resource name /// Resource type - /// State of the alert (Active, Dismissed - /// etc.) - /// The time the incident was reported to - /// Microsoft.Security in UTC - /// Name of the vendor that discovered the - /// incident - /// Name of the alert type - /// Display name of the alert - /// type - /// The time the incident was detected by - /// the vendor - /// Description of the incident and what it - /// means - /// Recommended steps to reradiate the - /// incident - /// The action that was taken as a response - /// to the alert (Active, Blocked etc.) - /// Estimated severity of this alert. + /// Unique identifier for the detection logic + /// (all alert instances from the same detection logic will have the + /// same alertType). + /// Unique identifier for the + /// alert. + /// The name of Azure Security + /// Center pricing tier which powering this alert. Learn more: + /// https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing + /// The display name of the + /// alert. + /// Description of the suspicious activity + /// that was detected. + /// The risk level of the threat that was + /// detected. Learn more: + /// https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. /// Possible values include: 'Informational', 'Low', 'Medium', /// 'High' - /// The entity that the incident - /// happened on - /// Azure resource ID of the - /// associated resource - /// The type of the alerted resource (Azure, - /// Non-Azure) - /// Whether this alert can be - /// investigated with Azure Security Center - /// Whether this alert is for incident type or - /// not (otherwise - single alert) - /// objects that are related to this - /// alerts - /// level of confidence we have on the - /// alert - /// reasons the alert got the - /// confidenceScore value - /// Azure subscription ID of the resource - /// that had the security alert or the subscription ID of the workspace - /// that this resource reports to - /// Instance ID of the alert. - /// Azure resource ID of the workspace - /// that the alert was reported to. - /// Alerts with the same CorrelationKey - /// will be grouped together in Ibiza. - public Alert(string id = default(string), string name = default(string), string type = default(string), string state = default(string), System.DateTime? reportedTimeUtc = default(System.DateTime?), string vendorName = default(string), string alertName = default(string), string alertDisplayName = default(string), System.DateTime? detectedTimeUtc = default(System.DateTime?), string description = default(string), string remediationSteps = default(string), string actionTaken = default(string), string reportedSeverity = default(string), string compromisedEntity = default(string), string associatedResource = default(string), IDictionary extendedProperties = default(IDictionary), string systemSource = default(string), bool? canBeInvestigated = default(bool?), bool? isIncident = default(bool?), IList entities = default(IList), double? confidenceScore = default(double?), IList confidenceReasons = default(IList), string subscriptionId = default(string), string instanceId = default(string), string workspaceArmId = default(string), string correlationKey = default(string)) + /// The kill chain related intent behind the + /// alert. For list of supported values, and explanations of Azure + /// Security Center's supported kill chain intents. Possible values + /// include: 'Unknown', 'PreAttack', 'InitialAccess', 'Persistence', + /// 'PrivilegeEscalation', 'DefenseEvasion', 'CredentialAccess', + /// 'Discovery', 'LateralMovement', 'Execution', 'Collection', + /// 'Exfiltration', 'CommandAndControl', 'Impact', 'Probing', + /// 'Exploitation' + /// The UTC time of the first event or + /// activity included in the alert in ISO8601 format. + /// The UTC time of the last event or activity + /// included in the alert in ISO8601 format. + /// The resource identifiers that can + /// be used to direct the alert to the right product exposure group + /// (tenant, workspace, subscription etc.). There can be multiple + /// identifiers of different type per alert. + /// Manual action items to take to + /// remediate the alert. + /// The name of the vendor that raises the + /// alert. + /// The life cycle status of the alert. Possible + /// values include: 'Active', 'Resolved', 'Dismissed' + /// Links related to the alert + /// A direct link to the alert page in Azure + /// Portal. + /// The UTC time the alert was generated + /// in ISO8601 format. + /// The name of the product which published + /// this alert (Azure Security Center, Azure ATP, Microsoft Defender + /// ATP, O365 ATP, MCAS, and so on). + /// The UTC processing end time of + /// the alert in ISO8601 format. + /// A list of entities related to the + /// alert. + /// This field determines whether the alert is + /// an incident (a compound grouping of several alerts) or a single + /// alert. + /// Key for corelating related alerts. + /// Alerts with the same correlation key considered to be + /// related. + /// Custom properties for the + /// alert. + /// The display name of the resource + /// most related to this alert. + public Alert(string id = default(string), string name = default(string), string type = default(string), string alertType = default(string), string systemAlertId = default(string), string productComponentName = default(string), string alertDisplayName = default(string), string description = default(string), string severity = default(string), string intent = default(string), System.DateTime? startTimeUtc = default(System.DateTime?), System.DateTime? endTimeUtc = default(System.DateTime?), IList resourceIdentifiers = default(IList), IList remediationSteps = default(IList), string vendorName = default(string), string status = default(string), IList> extendedLinks = default(IList>), string alertUri = default(string), System.DateTime? timeGeneratedUtc = default(System.DateTime?), string productName = default(string), System.DateTime? processingEndTimeUtc = default(System.DateTime?), IList entities = default(IList), bool? isIncident = default(bool?), string correlationKey = default(string), IDictionary extendedProperties = default(IDictionary), string compromisedEntity = default(string)) : base(id, name, type) { - State = state; - ReportedTimeUtc = reportedTimeUtc; - VendorName = vendorName; - AlertName = alertName; + AlertType = alertType; + SystemAlertId = systemAlertId; + ProductComponentName = productComponentName; AlertDisplayName = alertDisplayName; - DetectedTimeUtc = detectedTimeUtc; Description = description; + Severity = severity; + Intent = intent; + StartTimeUtc = startTimeUtc; + EndTimeUtc = endTimeUtc; + ResourceIdentifiers = resourceIdentifiers; RemediationSteps = remediationSteps; - ActionTaken = actionTaken; - ReportedSeverity = reportedSeverity; - CompromisedEntity = compromisedEntity; - AssociatedResource = associatedResource; - ExtendedProperties = extendedProperties; - SystemSource = systemSource; - CanBeInvestigated = canBeInvestigated; - IsIncident = isIncident; + VendorName = vendorName; + Status = status; + ExtendedLinks = extendedLinks; + AlertUri = alertUri; + TimeGeneratedUtc = timeGeneratedUtc; + ProductName = productName; + ProcessingEndTimeUtc = processingEndTimeUtc; Entities = entities; - ConfidenceScore = confidenceScore; - ConfidenceReasons = confidenceReasons; - SubscriptionId = subscriptionId; - InstanceId = instanceId; - WorkspaceArmId = workspaceArmId; + IsIncident = isIncident; CorrelationKey = correlationKey; + ExtendedProperties = extendedProperties; + CompromisedEntity = compromisedEntity; CustomInit(); } @@ -116,167 +133,163 @@ public Alert() partial void CustomInit(); /// - /// Gets state of the alert (Active, Dismissed etc.) + /// Gets unique identifier for the detection logic (all alert instances + /// from the same detection logic will have the same alertType). /// - [JsonProperty(PropertyName = "properties.state")] - public string State { get; private set; } + [JsonProperty(PropertyName = "properties.alertType")] + public string AlertType { get; private set; } /// - /// Gets the time the incident was reported to Microsoft.Security in - /// UTC + /// Gets unique identifier for the alert. /// - [JsonProperty(PropertyName = "properties.reportedTimeUtc")] - public System.DateTime? ReportedTimeUtc { get; private set; } + [JsonProperty(PropertyName = "properties.systemAlertId")] + public string SystemAlertId { get; private set; } /// - /// Gets name of the vendor that discovered the incident + /// Gets the name of Azure Security Center pricing tier which powering + /// this alert. Learn more: + /// https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing /// - [JsonProperty(PropertyName = "properties.vendorName")] - public string VendorName { get; private set; } + [JsonProperty(PropertyName = "properties.productComponentName")] + public string ProductComponentName { get; private set; } /// - /// Gets name of the alert type - /// - [JsonProperty(PropertyName = "properties.alertName")] - public string AlertName { get; private set; } - - /// - /// Gets display name of the alert type + /// Gets the display name of the alert. /// [JsonProperty(PropertyName = "properties.alertDisplayName")] public string AlertDisplayName { get; private set; } /// - /// Gets the time the incident was detected by the vendor - /// - [JsonProperty(PropertyName = "properties.detectedTimeUtc")] - public System.DateTime? DetectedTimeUtc { get; private set; } - - /// - /// Gets description of the incident and what it means + /// Gets description of the suspicious activity that was detected. /// [JsonProperty(PropertyName = "properties.description")] public string Description { get; private set; } /// - /// Gets recommended steps to reradiate the incident + /// Gets the risk level of the threat that was detected. Learn more: + /// https://docs.microsoft.com/en-us/azure/security-center/security-center-alerts-overview#how-are-alerts-classified. + /// Possible values include: 'Informational', 'Low', 'Medium', 'High' /// - [JsonProperty(PropertyName = "properties.remediationSteps")] - public string RemediationSteps { get; private set; } + [JsonProperty(PropertyName = "properties.severity")] + public string Severity { get; private set; } /// - /// Gets the action that was taken as a response to the alert (Active, - /// Blocked etc.) + /// Gets the kill chain related intent behind the alert. For list of + /// supported values, and explanations of Azure Security Center's + /// supported kill chain intents. Possible values include: 'Unknown', + /// 'PreAttack', 'InitialAccess', 'Persistence', 'PrivilegeEscalation', + /// 'DefenseEvasion', 'CredentialAccess', 'Discovery', + /// 'LateralMovement', 'Execution', 'Collection', 'Exfiltration', + /// 'CommandAndControl', 'Impact', 'Probing', 'Exploitation' /// - [JsonProperty(PropertyName = "properties.actionTaken")] - public string ActionTaken { get; private set; } + [JsonProperty(PropertyName = "properties.intent")] + public string Intent { get; private set; } /// - /// Gets estimated severity of this alert. Possible values include: - /// 'Informational', 'Low', 'Medium', 'High' + /// Gets the UTC time of the first event or activity included in the + /// alert in ISO8601 format. /// - [JsonProperty(PropertyName = "properties.reportedSeverity")] - public string ReportedSeverity { get; private set; } + [JsonProperty(PropertyName = "properties.startTimeUtc")] + public System.DateTime? StartTimeUtc { get; private set; } /// - /// Gets the entity that the incident happened on + /// Gets the UTC time of the last event or activity included in the + /// alert in ISO8601 format. /// - [JsonProperty(PropertyName = "properties.compromisedEntity")] - public string CompromisedEntity { get; private set; } + [JsonProperty(PropertyName = "properties.endTimeUtc")] + public System.DateTime? EndTimeUtc { get; private set; } /// - /// Gets azure resource ID of the associated resource + /// Gets the resource identifiers that can be used to direct the alert + /// to the right product exposure group (tenant, workspace, + /// subscription etc.). There can be multiple identifiers of different + /// type per alert. /// - [JsonProperty(PropertyName = "properties.associatedResource")] - public string AssociatedResource { get; private set; } + [JsonProperty(PropertyName = "properties.resourceIdentifiers")] + public IList ResourceIdentifiers { get; private set; } /// + /// Gets manual action items to take to remediate the alert. /// - [JsonProperty(PropertyName = "properties.extendedProperties")] - public IDictionary ExtendedProperties { get; set; } + [JsonProperty(PropertyName = "properties.remediationSteps")] + public IList RemediationSteps { get; private set; } /// - /// Gets the type of the alerted resource (Azure, Non-Azure) + /// Gets the name of the vendor that raises the alert. /// - [JsonProperty(PropertyName = "properties.systemSource")] - public string SystemSource { get; private set; } + [JsonProperty(PropertyName = "properties.vendorName")] + public string VendorName { get; private set; } /// - /// Gets whether this alert can be investigated with Azure Security - /// Center + /// Gets the life cycle status of the alert. Possible values include: + /// 'Active', 'Resolved', 'Dismissed' /// - [JsonProperty(PropertyName = "properties.canBeInvestigated")] - public bool? CanBeInvestigated { get; private set; } + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; private set; } /// - /// Gets whether this alert is for incident type or not (otherwise - - /// single alert) + /// Gets links related to the alert /// - [JsonProperty(PropertyName = "properties.isIncident")] - public bool? IsIncident { get; private set; } + [JsonProperty(PropertyName = "properties.extendedLinks")] + public IList> ExtendedLinks { get; private set; } /// - /// Gets or sets objects that are related to this alerts + /// Gets a direct link to the alert page in Azure Portal. /// - [JsonProperty(PropertyName = "properties.entities")] - public IList Entities { get; set; } + [JsonProperty(PropertyName = "properties.alertUri")] + public string AlertUri { get; private set; } /// - /// Gets level of confidence we have on the alert + /// Gets the UTC time the alert was generated in ISO8601 format. /// - [JsonProperty(PropertyName = "properties.confidenceScore")] - public double? ConfidenceScore { get; private set; } + [JsonProperty(PropertyName = "properties.timeGeneratedUtc")] + public System.DateTime? TimeGeneratedUtc { get; private set; } /// - /// Gets or sets reasons the alert got the confidenceScore value + /// Gets the name of the product which published this alert (Azure + /// Security Center, Azure ATP, Microsoft Defender ATP, O365 ATP, MCAS, + /// and so on). /// - [JsonProperty(PropertyName = "properties.confidenceReasons")] - public IList ConfidenceReasons { get; set; } + [JsonProperty(PropertyName = "properties.productName")] + public string ProductName { get; private set; } /// - /// Gets azure subscription ID of the resource that had the security - /// alert or the subscription ID of the workspace that this resource - /// reports to + /// Gets the UTC processing end time of the alert in ISO8601 format. /// - [JsonProperty(PropertyName = "properties.subscriptionId")] - public string SubscriptionId { get; private set; } + [JsonProperty(PropertyName = "properties.processingEndTimeUtc")] + public System.DateTime? ProcessingEndTimeUtc { get; private set; } /// - /// Gets instance ID of the alert. + /// Gets a list of entities related to the alert. /// - [JsonProperty(PropertyName = "properties.instanceId")] - public string InstanceId { get; private set; } + [JsonProperty(PropertyName = "properties.entities")] + public IList Entities { get; private set; } /// - /// Gets azure resource ID of the workspace that the alert was reported - /// to. + /// Gets this field determines whether the alert is an incident (a + /// compound grouping of several alerts) or a single alert. /// - [JsonProperty(PropertyName = "properties.workspaceArmId")] - public string WorkspaceArmId { get; private set; } + [JsonProperty(PropertyName = "properties.isIncident")] + public bool? IsIncident { get; private set; } /// - /// Gets alerts with the same CorrelationKey will be grouped together - /// in Ibiza. + /// Gets key for corelating related alerts. Alerts with the same + /// correlation key considered to be related. /// [JsonProperty(PropertyName = "properties.correlationKey")] public string CorrelationKey { get; private set; } /// - /// Validate the object. + /// Gets or sets custom properties for the alert. /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (ConfidenceScore > 1) - { - throw new ValidationException(ValidationRules.InclusiveMaximum, "ConfidenceScore", 1); - } - if (ConfidenceScore < 0) - { - throw new ValidationException(ValidationRules.InclusiveMinimum, "ConfidenceScore", 0); - } - } + [JsonProperty(PropertyName = "properties.extendedProperties")] + public IDictionary ExtendedProperties { get; set; } + + /// + /// Gets the display name of the resource most related to this alert. + /// + [JsonProperty(PropertyName = "properties.compromisedEntity")] + public string CompromisedEntity { get; private set; } + } } diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertIntent.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertIntent.cs new file mode 100644 index 000000000000..9ce004f76da4 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertIntent.cs @@ -0,0 +1,36 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for AlertIntent. + /// + public static class AlertIntent + { + public const string Unknown = "Unknown"; + public const string PreAttack = "PreAttack"; + public const string InitialAccess = "InitialAccess"; + public const string Persistence = "Persistence"; + public const string PrivilegeEscalation = "PrivilegeEscalation"; + public const string DefenseEvasion = "DefenseEvasion"; + public const string CredentialAccess = "CredentialAccess"; + public const string Discovery = "Discovery"; + public const string LateralMovement = "LateralMovement"; + public const string Execution = "Execution"; + public const string Collection = "Collection"; + public const string Exfiltration = "Exfiltration"; + public const string CommandAndControl = "CommandAndControl"; + public const string Impact = "Impact"; + public const string Probing = "Probing"; + public const string Exploitation = "Exploitation"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertSeverity.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertSeverity.cs new file mode 100644 index 000000000000..f205d7b00cbc --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertSeverity.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for AlertSeverity. + /// + public static class AlertSeverity + { + public const string Informational = "Informational"; + public const string Low = "Low"; + public const string Medium = "Medium"; + public const string High = "High"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertStatus.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertStatus.cs new file mode 100644 index 000000000000..a71003043b70 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertStatus.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for AlertStatus. + /// + public static class AlertStatus + { + /// + /// An alert which doesn't specify a value is assigned the status + /// 'Active' + /// + public const string Active = "Active"; + /// + /// Alert closed after handling + /// + public const string Resolved = "Resolved"; + /// + /// Alert dismissed as false positive + /// + public const string Dismissed = "Dismissed"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertsSuppressionRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertsSuppressionRule.cs new file mode 100644 index 000000000000..286a4e6ee6b3 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AlertsSuppressionRule.cs @@ -0,0 +1,137 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes the suppression rule + /// + [Rest.Serialization.JsonTransformation] + public partial class AlertsSuppressionRule : Resource + { + /// + /// Initializes a new instance of the AlertsSuppressionRule class. + /// + public AlertsSuppressionRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertsSuppressionRule class. + /// + /// Type of the alert to automatically + /// suppress. For all alert types, use '*' + /// The reason for dismissing the alert + /// Possible states of the rule. Possible values + /// include: 'Enabled', 'Disabled', 'Expired' + /// Resource Id + /// Resource name + /// Resource type + /// The last time this rule was + /// modified + /// Expiration date of the rule, if + /// value is not provided or provided as null this field will default + /// to the maximum allowed expiration date. + /// Any comment regarding the rule + /// The suppression + /// conditions + public AlertsSuppressionRule(string alertType, string reason, RuleState state, string id = default(string), string name = default(string), string type = default(string), System.DateTime? lastModifiedUtc = default(System.DateTime?), System.DateTime? expirationDateUtc = default(System.DateTime?), string comment = default(string), SuppressionAlertsScope suppressionAlertsScope = default(SuppressionAlertsScope)) + : base(id, name, type) + { + AlertType = alertType; + LastModifiedUtc = lastModifiedUtc; + ExpirationDateUtc = expirationDateUtc; + Reason = reason; + State = state; + Comment = comment; + SuppressionAlertsScope = suppressionAlertsScope; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets type of the alert to automatically suppress. For all + /// alert types, use '*' + /// + [JsonProperty(PropertyName = "properties.alertType")] + public string AlertType { get; set; } + + /// + /// Gets the last time this rule was modified + /// + [JsonProperty(PropertyName = "properties.lastModifiedUtc")] + public System.DateTime? LastModifiedUtc { get; private set; } + + /// + /// Gets or sets expiration date of the rule, if value is not provided + /// or provided as null this field will default to the maximum allowed + /// expiration date. + /// + [JsonProperty(PropertyName = "properties.expirationDateUtc")] + public System.DateTime? ExpirationDateUtc { get; set; } + + /// + /// Gets or sets the reason for dismissing the alert + /// + [JsonProperty(PropertyName = "properties.reason")] + public string Reason { get; set; } + + /// + /// Gets or sets possible states of the rule. Possible values include: + /// 'Enabled', 'Disabled', 'Expired' + /// + [JsonProperty(PropertyName = "properties.state")] + public RuleState State { get; set; } + + /// + /// Gets or sets any comment regarding the rule + /// + [JsonProperty(PropertyName = "properties.comment")] + public string Comment { get; set; } + + /// + /// Gets or sets the suppression conditions + /// + [JsonProperty(PropertyName = "properties.suppressionAlertsScope")] + public SuppressionAlertsScope SuppressionAlertsScope { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AlertType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AlertType"); + } + if (Reason == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Reason"); + } + if (SuppressionAlertsScope != null) + { + SuppressionAlertsScope.Validate(); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AllowlistCustomAlertRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AllowlistCustomAlertRule.cs index 9033e1abbffb..4f1823712b08 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AllowlistCustomAlertRule.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AllowlistCustomAlertRule.cs @@ -20,7 +20,6 @@ namespace Microsoft.Azure.Management.Security.Models /// A custom alert rule that checks if a value (depends on the custom alert /// type) is allowed. /// - [Newtonsoft.Json.JsonObject("AllowlistCustomAlertRule")] public partial class AllowlistCustomAlertRule : ListCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpC2DRejectedMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpC2DRejectedMessagesNotInAllowedRange.cs index 61375802e9ea..27ca3c49286e 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpC2DRejectedMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpC2DRejectedMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of rejected cloud to device messages (AMQP protocol) is not in /// allowed range. /// - [Newtonsoft.Json.JsonObject("AmqpC2DRejectedMessagesNotInAllowedRange")] public partial class AmqpC2DRejectedMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpD2CMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpD2CMessagesNotInAllowedRange.cs index fd6dd48b1060..8061c59a72ce 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpD2CMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AmqpD2CMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of device to cloud messages (AMQP protocol) is not in allowed /// range. /// - [Newtonsoft.Json.JsonObject("AmqpD2CMessagesNotInAllowedRange")] public partial class AmqpD2CMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthenticationDetailsProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthenticationDetailsProperties.cs new file mode 100644 index 000000000000..4e15389c098a --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthenticationDetailsProperties.cs @@ -0,0 +1,67 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Settings for cloud authentication management + /// + public partial class AuthenticationDetailsProperties + { + /// + /// Initializes a new instance of the AuthenticationDetailsProperties + /// class. + /// + public AuthenticationDetailsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AuthenticationDetailsProperties + /// class. + /// + /// State of the + /// multi-cloud connector. Possible values include: 'Valid', 'Invalid', + /// 'Expired', 'IncorrectPolicy' + /// The permissions detected in the + /// cloud account. + public AuthenticationDetailsProperties(string authenticationProvisioningState = default(string), IList grantedPermissions = default(IList)) + { + AuthenticationProvisioningState = authenticationProvisioningState; + GrantedPermissions = grantedPermissions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets state of the multi-cloud connector. Possible values include: + /// 'Valid', 'Invalid', 'Expired', 'IncorrectPolicy' + /// + [JsonProperty(PropertyName = "authenticationProvisioningState")] + public string AuthenticationProvisioningState { get; private set; } + + /// + /// Gets the permissions detected in the cloud account. + /// + [JsonProperty(PropertyName = "grantedPermissions")] + public IList GrantedPermissions { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthenticationProvisioningState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthenticationProvisioningState.cs new file mode 100644 index 000000000000..7db7aa930cd6 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthenticationProvisioningState.cs @@ -0,0 +1,36 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for AuthenticationProvisioningState. + /// + public static class AuthenticationProvisioningState + { + /// + /// Valid connector + /// + public const string Valid = "Valid"; + /// + /// Invalid connector + /// + public const string Invalid = "Invalid"; + /// + /// the connection has expired + /// + public const string Expired = "Expired"; + /// + /// Incorrect policy of the connector + /// + public const string IncorrectPolicy = "IncorrectPolicy"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthorizationState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthorizationState.cs new file mode 100644 index 000000000000..9e9673ebd32c --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AuthorizationState.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.Security.Models +{ + + /// + /// Defines values for AuthorizationState. + /// + public static class AuthorizationState + { + public const string Authorized = "Authorized"; + public const string Unauthorized = "Unauthorized"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationAction.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationAction.cs index e486a3ba01b9..921ecb8ffaf1 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationAction.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationAction.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// The action that should be triggered. /// - [Newtonsoft.Json.JsonObject("AutomationAction")] public partial class AutomationAction { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationSource.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationSource.cs index 24d0a95f8885..6b1e3456186d 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationSource.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AutomationSource.cs @@ -35,7 +35,8 @@ public AutomationSource() /// Initializes a new instance of the AutomationSource class. /// /// A valid event source type. Possible - /// values include: 'Assessments', 'Alerts' + /// values include: 'Assessments', 'SubAssessments', 'Alerts', + /// 'SecureScores', 'SecureScoreControls' /// A set of rules which evaluate upon event /// interception. A logical disjunction is applied between defined rule /// sets (logical 'or'). @@ -53,7 +54,8 @@ public AutomationSource() /// /// Gets or sets a valid event source type. Possible values include: - /// 'Assessments', 'Alerts' + /// 'Assessments', 'SubAssessments', 'Alerts', 'SecureScores', + /// 'SecureScoreControls' /// [JsonProperty(PropertyName = "eventSource")] public string EventSource { get; set; } diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AwAssumeRoleAuthenticationDetailsProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AwAssumeRoleAuthenticationDetailsProperties.cs new file mode 100644 index 000000000000..d23662cc5f9a --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AwAssumeRoleAuthenticationDetailsProperties.cs @@ -0,0 +1,105 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// AWS cloud account connector based assume role, the role enables + /// delegating access to your AWS resources. The role is composed of role + /// Amazon Resource Name (ARN) and external ID. For more details, refer to + /// <a + /// href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html">Creating + /// a Role to Delegate Permissions to an IAM User (write only)</a> + /// + [Newtonsoft.Json.JsonObject("awsAssumeRole")] + public partial class AwAssumeRoleAuthenticationDetailsProperties : AuthenticationDetailsProperties + { + /// + /// Initializes a new instance of the + /// AwAssumeRoleAuthenticationDetailsProperties class. + /// + public AwAssumeRoleAuthenticationDetailsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// AwAssumeRoleAuthenticationDetailsProperties class. + /// + /// Assumed role ID is an identifier + /// that you can use to create temporary security credentials. + /// A unique identifier that is required + /// when you assume a role in another account. + /// State of the + /// multi-cloud connector. Possible values include: 'Valid', 'Invalid', + /// 'Expired', 'IncorrectPolicy' + /// The permissions detected in the + /// cloud account. + /// The ID of the cloud account + public AwAssumeRoleAuthenticationDetailsProperties(string awsAssumeRoleArn, string awsExternalId, string authenticationProvisioningState = default(string), IList grantedPermissions = default(IList), string accountId = default(string)) + : base(authenticationProvisioningState, grantedPermissions) + { + AccountId = accountId; + AwsAssumeRoleArn = awsAssumeRoleArn; + AwsExternalId = awsExternalId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ID of the cloud account + /// + [JsonProperty(PropertyName = "accountId")] + public string AccountId { get; private set; } + + /// + /// Gets or sets assumed role ID is an identifier that you can use to + /// create temporary security credentials. + /// + [JsonProperty(PropertyName = "awsAssumeRoleArn")] + public string AwsAssumeRoleArn { get; set; } + + /// + /// Gets or sets a unique identifier that is required when you assume a + /// role in another account. + /// + [JsonProperty(PropertyName = "awsExternalId")] + public string AwsExternalId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AwsAssumeRoleArn == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AwsAssumeRoleArn"); + } + if (AwsExternalId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AwsExternalId"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AwsCredsAuthenticationDetailsProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AwsCredsAuthenticationDetailsProperties.cs new file mode 100644 index 000000000000..f934c6479f8f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AwsCredsAuthenticationDetailsProperties.cs @@ -0,0 +1,104 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// AWS cloud account connector based credentials, the credentials is + /// composed of access key ID and secret key, for more details, refer to + /// <a + /// href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html">Creating + /// an IAM User in Your AWS Account (write only)</a> + /// + [Newtonsoft.Json.JsonObject("awsCreds")] + public partial class AwsCredsAuthenticationDetailsProperties : AuthenticationDetailsProperties + { + /// + /// Initializes a new instance of the + /// AwsCredsAuthenticationDetailsProperties class. + /// + public AwsCredsAuthenticationDetailsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// AwsCredsAuthenticationDetailsProperties class. + /// + /// Public key element of the AWS + /// credential object (write only) + /// Secret key element of the AWS + /// credential object (write only) + /// State of the + /// multi-cloud connector. Possible values include: 'Valid', 'Invalid', + /// 'Expired', 'IncorrectPolicy' + /// The permissions detected in the + /// cloud account. + /// The ID of the cloud account + public AwsCredsAuthenticationDetailsProperties(string awsAccessKeyId, string awsSecretAccessKey, string authenticationProvisioningState = default(string), IList grantedPermissions = default(IList), string accountId = default(string)) + : base(authenticationProvisioningState, grantedPermissions) + { + AccountId = accountId; + AwsAccessKeyId = awsAccessKeyId; + AwsSecretAccessKey = awsSecretAccessKey; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ID of the cloud account + /// + [JsonProperty(PropertyName = "accountId")] + public string AccountId { get; private set; } + + /// + /// Gets or sets public key element of the AWS credential object (write + /// only) + /// + [JsonProperty(PropertyName = "awsAccessKeyId")] + public string AwsAccessKeyId { get; set; } + + /// + /// Gets or sets secret key element of the AWS credential object (write + /// only) + /// + [JsonProperty(PropertyName = "awsSecretAccessKey")] + public string AwsSecretAccessKey { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AwsAccessKeyId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AwsAccessKeyId"); + } + if (AwsSecretAccessKey == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AwsSecretAccessKey"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureResourceIdentifier.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureResourceIdentifier.cs new file mode 100644 index 000000000000..4bfd85f17cd3 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureResourceIdentifier.cs @@ -0,0 +1,54 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Azure resource identifier. + /// + [Newtonsoft.Json.JsonObject("AzureResource")] + public partial class AzureResourceIdentifier : ResourceIdentifier + { + /// + /// Initializes a new instance of the AzureResourceIdentifier class. + /// + public AzureResourceIdentifier() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureResourceIdentifier class. + /// + /// ARM resource identifier for the cloud + /// resource being alerted on + public AzureResourceIdentifier(string azureResourceId = default(string)) + { + AzureResourceId = azureResourceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ARM resource identifier for the cloud resource being alerted + /// on + /// + [JsonProperty(PropertyName = "azureResourceId")] + public string AzureResourceId { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureResourceLink.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureResourceLink.cs new file mode 100644 index 000000000000..d2d7d81bfbc5 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureResourceLink.cs @@ -0,0 +1,51 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes an Azure resource with kind + /// + public partial class AzureResourceLink + { + /// + /// Initializes a new instance of the AzureResourceLink class. + /// + public AzureResourceLink() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureResourceLink class. + /// + /// Azure resource Id + public AzureResourceLink(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets azure resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureTrackedResourceLocation.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureTrackedResourceLocation.cs new file mode 100644 index 000000000000..446d816f4f1d --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/AzureTrackedResourceLocation.cs @@ -0,0 +1,54 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes an Azure resource with location + /// + public partial class AzureTrackedResourceLocation + { + /// + /// Initializes a new instance of the AzureTrackedResourceLocation + /// class. + /// + public AzureTrackedResourceLocation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureTrackedResourceLocation + /// class. + /// + /// Location where the resource is + /// stored + public AzureTrackedResourceLocation(string location = default(string)) + { + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets location where the resource is stored + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Baseline.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Baseline.cs new file mode 100644 index 000000000000..a300c7515832 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Baseline.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Baseline details. + /// + public partial class Baseline + { + /// + /// Initializes a new instance of the Baseline class. + /// + public Baseline() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Baseline class. + /// + /// Expected results. + /// Baseline update time (UTC). + public Baseline(IList> expectedResults = default(IList>), System.DateTime? updatedTime = default(System.DateTime?)) + { + ExpectedResults = expectedResults; + UpdatedTime = updatedTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets expected results. + /// + [JsonProperty(PropertyName = "expectedResults")] + public IList> ExpectedResults { get; set; } + + /// + /// Gets or sets baseline update time (UTC). + /// + [JsonProperty(PropertyName = "updatedTime")] + public System.DateTime? UpdatedTime { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/BaselineAdjustedResult.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/BaselineAdjustedResult.cs new file mode 100644 index 000000000000..29e81afc6670 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/BaselineAdjustedResult.cs @@ -0,0 +1,79 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The rule result adjusted with baseline. + /// + public partial class BaselineAdjustedResult + { + /// + /// Initializes a new instance of the BaselineAdjustedResult class. + /// + public BaselineAdjustedResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BaselineAdjustedResult class. + /// + /// Possible values include: 'NonFinding', + /// 'Finding', 'InternalError' + /// Results the are not in + /// baseline. + /// Results the are in + /// baseline. + public BaselineAdjustedResult(Baseline baseline = default(Baseline), string status = default(string), IList> resultsNotInBaseline = default(IList>), IList> resultsOnlyInBaseline = default(IList>)) + { + Baseline = baseline; + Status = status; + ResultsNotInBaseline = resultsNotInBaseline; + ResultsOnlyInBaseline = resultsOnlyInBaseline; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "baseline")] + public Baseline Baseline { get; set; } + + /// + /// Gets or sets possible values include: 'NonFinding', 'Finding', + /// 'InternalError' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets results the are not in baseline. + /// + [JsonProperty(PropertyName = "resultsNotInBaseline")] + public IList> ResultsNotInBaseline { get; set; } + + /// + /// Gets or sets results the are in baseline. + /// + [JsonProperty(PropertyName = "resultsOnlyInBaseline")] + public IList> ResultsOnlyInBaseline { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/BenchmarkReference.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/BenchmarkReference.cs new file mode 100644 index 000000000000..f730db7e5513 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/BenchmarkReference.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The benchmark references. + /// + public partial class BenchmarkReference + { + /// + /// Initializes a new instance of the BenchmarkReference class. + /// + public BenchmarkReference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BenchmarkReference class. + /// + /// The benchmark name. + /// The benchmark reference. + public BenchmarkReference(string benchmark = default(string), string reference = default(string)) + { + Benchmark = benchmark; + Reference = reference; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the benchmark name. + /// + [JsonProperty(PropertyName = "benchmark")] + public string Benchmark { get; set; } + + /// + /// Gets or sets the benchmark reference. + /// + [JsonProperty(PropertyName = "reference")] + public string Reference { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectionToIpNotAllowed.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectionToIpNotAllowed.cs index 19cc63c8934c..16d02941054a 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectionToIpNotAllowed.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectionToIpNotAllowed.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -19,7 +18,6 @@ namespace Microsoft.Azure.Management.Security.Models /// Outbound connection to an ip that isn't allowed. Allow list consists of /// ipv4 or ipv6 range in CIDR notation. /// - [Newtonsoft.Json.JsonObject("ConnectionToIpNotAllowed")] public partial class ConnectionToIpNotAllowed : AllowlistCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectorSetting.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectorSetting.cs new file mode 100644 index 000000000000..e99d45471912 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ConnectorSetting.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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The connector setting + /// + [Rest.Serialization.JsonTransformation] + public partial class ConnectorSetting : Resource + { + /// + /// Initializes a new instance of the ConnectorSetting class. + /// + public ConnectorSetting() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConnectorSetting class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// Settings for hybrid compute + /// management. These settings are relevant only for Arc autoProvision + /// (Hybrid Compute). + /// Settings for authentication + /// management, these settings are relevant only for the cloud + /// connector. + public ConnectorSetting(string id = default(string), string name = default(string), string type = default(string), HybridComputeSettingsProperties hybridComputeSettings = default(HybridComputeSettingsProperties), AuthenticationDetailsProperties authenticationDetails = default(AuthenticationDetailsProperties)) + : base(id, name, type) + { + HybridComputeSettings = hybridComputeSettings; + AuthenticationDetails = authenticationDetails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets settings for hybrid compute management. These settings + /// are relevant only for Arc autoProvision (Hybrid Compute). + /// + [JsonProperty(PropertyName = "properties.hybridComputeSettings")] + public HybridComputeSettingsProperties HybridComputeSettings { get; set; } + + /// + /// Gets or sets settings for authentication management, these settings + /// are relevant only for the cloud connector. + /// + [JsonProperty(PropertyName = "properties.authenticationDetails")] + public AuthenticationDetailsProperties AuthenticationDetails { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (HybridComputeSettings != null) + { + HybridComputeSettings.Validate(); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ControlType.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ControlType.cs new file mode 100644 index 000000000000..dc6e20143b2a --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ControlType.cs @@ -0,0 +1,28 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for ControlType. + /// + public static class ControlType + { + /// + /// Azure Security Center managed assessments + /// + public const string BuiltIn = "BuiltIn"; + /// + /// Non Azure Security Center managed assessments + /// + public const string Custom = "Custom"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/CustomAlertRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/CustomAlertRule.cs index a581bbf4f832..c52d16896c22 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/CustomAlertRule.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/CustomAlertRule.cs @@ -16,7 +16,6 @@ namespace Microsoft.Azure.Management.Security.Models /// /// A custom alert rule. /// - [Newtonsoft.Json.JsonObject("CustomAlertRule")] public partial class CustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DenylistCustomAlertRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DenylistCustomAlertRule.cs index 1bfe4ef2944a..fefdebb7ccad 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DenylistCustomAlertRule.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DenylistCustomAlertRule.cs @@ -20,7 +20,6 @@ namespace Microsoft.Azure.Management.Security.Models /// A custom alert rule that checks if a value (depends on the custom alert /// type) is denied. /// - [Newtonsoft.Json.JsonObject("DenylistCustomAlertRule")] public partial class DenylistCustomAlertRule : ListCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Device.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Device.cs new file mode 100644 index 000000000000..1e41a249b2cf --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Device.cs @@ -0,0 +1,282 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Device model + /// + [Rest.Serialization.JsonTransformation] + public partial class Device : Resource + { + /// + /// Initializes a new instance of the Device class. + /// + public Device() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Device class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// Device display name given by the + /// collector + /// Device type. + /// The source that created the device + /// List of network interfaces. + /// Device vendor + /// Device operating system name. + /// List of protocols. + /// last time the device was active in the + /// network + /// last time the device was + /// updated + /// Managed state of the device. Possible + /// values include: 'Managed', 'Unmanaged' + /// Authorized state of the device. + /// Possible values include: 'Authorized', 'Unauthorized' + /// Device criticality. Possible values + /// include: 'Important', 'Standard' + /// Purdue level of the device. Possible + /// values include: 'ProcessControl', 'Supervisory', + /// 'Enterprise' + /// user notes for the device, up to 300 + /// characters. + /// List of device firmwares. + /// Discovered time of the device. + /// Indicates whether this device is + /// programming. Possible values include: 'ProgrammingDevice', + /// 'NotProgrammingDevice' + /// last time the device was + /// programming or programed. + /// Indicates whether the device is + /// a scanner. Possible values include: 'ScannerDevice', + /// 'NotScannerDevice' + /// last time the device was + /// scanning. + /// risk score of the device. + /// List of sensors that scanned this + /// device. + /// Device status. Possible values include: + /// 'Active', 'Removed' + public Device(string id = default(string), string name = default(string), string type = default(string), string displayName = default(string), string deviceType = default(string), string sourceName = default(string), IList networkInterfaces = default(IList), string vendor = default(string), string osName = default(string), IList protocols = default(IList), System.DateTime? lastActiveTime = default(System.DateTime?), System.DateTime? lastUpdateTime = default(System.DateTime?), string managementState = default(string), string authorizationState = default(string), string deviceCriticality = default(string), string purdueLevel = default(string), string notes = default(string), IList firmwares = default(IList), System.DateTime? discoveryTime = default(System.DateTime?), string programmingState = default(string), System.DateTime? lastProgrammingTime = default(System.DateTime?), string scanningFunctionality = default(string), System.DateTime? lastScanTime = default(System.DateTime?), int? riskScore = default(int?), IList sensors = default(IList), Site site = default(Site), string deviceStatus = default(string)) + : base(id, name, type) + { + DisplayName = displayName; + DeviceType = deviceType; + SourceName = sourceName; + NetworkInterfaces = networkInterfaces; + Vendor = vendor; + OsName = osName; + Protocols = protocols; + LastActiveTime = lastActiveTime; + LastUpdateTime = lastUpdateTime; + ManagementState = managementState; + AuthorizationState = authorizationState; + DeviceCriticality = deviceCriticality; + PurdueLevel = purdueLevel; + Notes = notes; + Firmwares = firmwares; + DiscoveryTime = discoveryTime; + ProgrammingState = programmingState; + LastProgrammingTime = lastProgrammingTime; + ScanningFunctionality = scanningFunctionality; + LastScanTime = lastScanTime; + RiskScore = riskScore; + Sensors = sensors; + Site = site; + DeviceStatus = deviceStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets device display name given by the collector + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets device type. + /// + [JsonProperty(PropertyName = "properties.deviceType")] + public string DeviceType { get; set; } + + /// + /// Gets the source that created the device + /// + [JsonProperty(PropertyName = "properties.sourceName")] + public string SourceName { get; private set; } + + /// + /// Gets list of network interfaces. + /// + [JsonProperty(PropertyName = "properties.networkInterfaces")] + public IList NetworkInterfaces { get; private set; } + + /// + /// Gets device vendor + /// + [JsonProperty(PropertyName = "properties.vendor")] + public string Vendor { get; private set; } + + /// + /// Gets or sets device operating system name. + /// + [JsonProperty(PropertyName = "properties.osName")] + public string OsName { get; set; } + + /// + /// Gets list of protocols. + /// + [JsonProperty(PropertyName = "properties.protocols")] + public IList Protocols { get; private set; } + + /// + /// Gets last time the device was active in the network + /// + [JsonProperty(PropertyName = "properties.lastActiveTime")] + public System.DateTime? LastActiveTime { get; private set; } + + /// + /// Gets last time the device was updated + /// + [JsonProperty(PropertyName = "properties.lastUpdateTime")] + public System.DateTime? LastUpdateTime { get; private set; } + + /// + /// Gets managed state of the device. Possible values include: + /// 'Managed', 'Unmanaged' + /// + [JsonProperty(PropertyName = "properties.managementState")] + public string ManagementState { get; private set; } + + /// + /// Gets or sets authorized state of the device. Possible values + /// include: 'Authorized', 'Unauthorized' + /// + [JsonProperty(PropertyName = "properties.authorizationState")] + public string AuthorizationState { get; set; } + + /// + /// Gets or sets device criticality. Possible values include: + /// 'Important', 'Standard' + /// + [JsonProperty(PropertyName = "properties.deviceCriticality")] + public string DeviceCriticality { get; set; } + + /// + /// Gets or sets purdue level of the device. Possible values include: + /// 'ProcessControl', 'Supervisory', 'Enterprise' + /// + [JsonProperty(PropertyName = "properties.purdueLevel")] + public string PurdueLevel { get; set; } + + /// + /// Gets or sets user notes for the device, up to 300 characters. + /// + [JsonProperty(PropertyName = "properties.notes")] + public string Notes { get; set; } + + /// + /// Gets list of device firmwares. + /// + [JsonProperty(PropertyName = "properties.firmwares")] + public IList Firmwares { get; private set; } + + /// + /// Gets discovered time of the device. + /// + [JsonProperty(PropertyName = "properties.discoveryTime")] + public System.DateTime? DiscoveryTime { get; private set; } + + /// + /// Gets indicates whether this device is programming. Possible values + /// include: 'ProgrammingDevice', 'NotProgrammingDevice' + /// + [JsonProperty(PropertyName = "properties.programmingState")] + public string ProgrammingState { get; private set; } + + /// + /// Gets last time the device was programming or programed. + /// + [JsonProperty(PropertyName = "properties.lastProgrammingTime")] + public System.DateTime? LastProgrammingTime { get; private set; } + + /// + /// Gets indicates whether the device is a scanner. Possible values + /// include: 'ScannerDevice', 'NotScannerDevice' + /// + [JsonProperty(PropertyName = "properties.scanningFunctionality")] + public string ScanningFunctionality { get; private set; } + + /// + /// Gets last time the device was scanning. + /// + [JsonProperty(PropertyName = "properties.lastScanTime")] + public System.DateTime? LastScanTime { get; private set; } + + /// + /// Gets risk score of the device. + /// + [JsonProperty(PropertyName = "properties.riskScore")] + public int? RiskScore { get; private set; } + + /// + /// Gets list of sensors that scanned this device. + /// + [JsonProperty(PropertyName = "properties.sensors")] + public IList Sensors { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties.site")] + public Site Site { get; private set; } + + /// + /// Gets device status. Possible values include: 'Active', 'Removed' + /// + [JsonProperty(PropertyName = "properties.deviceStatus")] + public string DeviceStatus { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RiskScore > 100) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "RiskScore", 100); + } + if (RiskScore < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "RiskScore", 0); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DeviceCriticality.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DeviceCriticality.cs new file mode 100644 index 000000000000..e463f8a38c99 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DeviceCriticality.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.Security.Models +{ + + /// + /// Defines values for DeviceCriticality. + /// + public static class DeviceCriticality + { + public const string Important = "Important"; + public const string Standard = "Standard"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DeviceStatus.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DeviceStatus.cs new file mode 100644 index 000000000000..f14d47f34441 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DeviceStatus.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.Security.Models +{ + + /// + /// Defines values for DeviceStatus. + /// + public static class DeviceStatus + { + public const string Active = "Active"; + public const string Removed = "Removed"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DirectMethodInvokesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DirectMethodInvokesNotInAllowedRange.cs index 5965d3547967..efb160b104ec 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DirectMethodInvokesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/DirectMethodInvokesNotInAllowedRange.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of direct method invokes is not in allowed range. /// - [Newtonsoft.Json.JsonObject("DirectMethodInvokesNotInAllowedRange")] public partial class DirectMethodInvokesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/EventSource.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/EventSource.cs index 43f4452ed9cd..00db614b2830 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/EventSource.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/EventSource.cs @@ -17,6 +17,9 @@ namespace Microsoft.Azure.Management.Security.Models public static class EventSource { public const string Assessments = "Assessments"; + public const string SubAssessments = "SubAssessments"; public const string Alerts = "Alerts"; + public const string SecureScores = "SecureScores"; + public const string SecureScoreControls = "SecureScoreControls"; } } diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExpandControlsEnum.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExpandControlsEnum.cs new file mode 100644 index 000000000000..e9d717ddacba --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExpandControlsEnum.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for ExpandControlsEnum. + /// + public static class ExpandControlsEnum + { + /// + /// Add definition object for each control + /// + public const string Definition = "definition"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExternalSecuritySolution.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExternalSecuritySolution.cs index 6391dffca8f2..119f870c19ad 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExternalSecuritySolution.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ExternalSecuritySolution.cs @@ -18,7 +18,6 @@ namespace Microsoft.Azure.Management.Security.Models /// sends information to an OMS workspace and whose data is displayed by /// Azure Security Center. /// - [Newtonsoft.Json.JsonObject("ExternalSecuritySolution")] public partial class ExternalSecuritySolution { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FailedLocalLoginsNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FailedLocalLoginsNotInAllowedRange.cs index 940afb4c7ce2..d2d8d1166ae2 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FailedLocalLoginsNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FailedLocalLoginsNotInAllowedRange.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of failed local logins is not in allowed range. /// - [Newtonsoft.Json.JsonObject("FailedLocalLoginsNotInAllowedRange")] public partial class FailedLocalLoginsNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FileUploadsNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FileUploadsNotInAllowedRange.cs index b35c49246449..55109af42dc0 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FileUploadsNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/FileUploadsNotInAllowedRange.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of file uploads is not in allowed range. /// - [Newtonsoft.Json.JsonObject("FileUploadsNotInAllowedRange")] public partial class FileUploadsNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Firmware.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Firmware.cs new file mode 100644 index 000000000000..8ba7a03c5320 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Firmware.cs @@ -0,0 +1,103 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Firmware information + /// + public partial class Firmware + { + /// + /// Initializes a new instance of the Firmware class. + /// + public Firmware() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Firmware class. + /// + /// Address of the specific module a + /// firmware is related to + /// Rack number of the module a firmware is related + /// to. + /// Slot number in the rack of the module a firmware + /// is related to + /// Serial of the firmware + /// Firmware model + /// Firmware version + /// A bag of fields which extends the + /// firmware information. + public Firmware(string moduleAddress = default(string), string rack = default(string), string slot = default(string), string serial = default(string), string model = default(string), string version = default(string), object additionalData = default(object)) + { + ModuleAddress = moduleAddress; + Rack = rack; + Slot = slot; + Serial = serial; + Model = model; + Version = version; + AdditionalData = additionalData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets address of the specific module a firmware is related to + /// + [JsonProperty(PropertyName = "moduleAddress")] + public string ModuleAddress { get; private set; } + + /// + /// Gets rack number of the module a firmware is related to. + /// + [JsonProperty(PropertyName = "rack")] + public string Rack { get; private set; } + + /// + /// Gets slot number in the rack of the module a firmware is related to + /// + [JsonProperty(PropertyName = "slot")] + public string Slot { get; private set; } + + /// + /// Gets serial of the firmware + /// + [JsonProperty(PropertyName = "serial")] + public string Serial { get; private set; } + + /// + /// Gets firmware model + /// + [JsonProperty(PropertyName = "model")] + public string Model { get; private set; } + + /// + /// Gets firmware version + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; private set; } + + /// + /// Gets A bag of fields which extends the firmware information. + /// + [JsonProperty(PropertyName = "additionalData")] + public object AdditionalData { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/GcpCredentialsDetailsProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/GcpCredentialsDetailsProperties.cs new file mode 100644 index 000000000000..946e5ec735eb --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/GcpCredentialsDetailsProperties.cs @@ -0,0 +1,210 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// GCP cloud account connector based service to service credentials, the + /// credentials are composed of the organization ID and a JSON API key + /// (write only) + /// + [Newtonsoft.Json.JsonObject("gcpCredentials")] + public partial class GcpCredentialsDetailsProperties : AuthenticationDetailsProperties + { + /// + /// Initializes a new instance of the GcpCredentialsDetailsProperties + /// class. + /// + public GcpCredentialsDetailsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GcpCredentialsDetailsProperties + /// class. + /// + /// The organization ID of the GCP cloud + /// account + /// Type field of the API key (write only) + /// Project ID field of the API key (write + /// only) + /// Private key ID field of the API key + /// (write only) + /// Private key field of the API key (write + /// only) + /// Client email field of the API key (write + /// only) + /// Client ID field of the API key (write + /// only) + /// Auth URI field of the API key (write + /// only) + /// Token URI field of the API key (write + /// only) + /// Auth provider x509 + /// certificate URL field of the API key (write only) + /// Client x509 certificate URL field + /// of the API key (write only) + /// State of the + /// multi-cloud connector. Possible values include: 'Valid', 'Invalid', + /// 'Expired', 'IncorrectPolicy' + /// The permissions detected in the + /// cloud account. + public GcpCredentialsDetailsProperties(string organizationId, string type, string projectId, string privateKeyId, string privateKey, string clientEmail, string clientId, string authUri, string tokenUri, string authProviderX509CertUrl, string clientX509CertUrl, string authenticationProvisioningState = default(string), IList grantedPermissions = default(IList)) + : base(authenticationProvisioningState, grantedPermissions) + { + OrganizationId = organizationId; + Type = type; + ProjectId = projectId; + PrivateKeyId = privateKeyId; + PrivateKey = privateKey; + ClientEmail = clientEmail; + ClientId = clientId; + AuthUri = authUri; + TokenUri = tokenUri; + AuthProviderX509CertUrl = authProviderX509CertUrl; + ClientX509CertUrl = clientX509CertUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the organization ID of the GCP cloud account + /// + [JsonProperty(PropertyName = "organizationId")] + public string OrganizationId { get; set; } + + /// + /// Gets or sets type field of the API key (write only) + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets project ID field of the API key (write only) + /// + [JsonProperty(PropertyName = "projectId")] + public string ProjectId { get; set; } + + /// + /// Gets or sets private key ID field of the API key (write only) + /// + [JsonProperty(PropertyName = "privateKeyId")] + public string PrivateKeyId { get; set; } + + /// + /// Gets or sets private key field of the API key (write only) + /// + [JsonProperty(PropertyName = "privateKey")] + public string PrivateKey { get; set; } + + /// + /// Gets or sets client email field of the API key (write only) + /// + [JsonProperty(PropertyName = "clientEmail")] + public string ClientEmail { get; set; } + + /// + /// Gets or sets client ID field of the API key (write only) + /// + [JsonProperty(PropertyName = "clientId")] + public string ClientId { get; set; } + + /// + /// Gets or sets auth URI field of the API key (write only) + /// + [JsonProperty(PropertyName = "authUri")] + public string AuthUri { get; set; } + + /// + /// Gets or sets token URI field of the API key (write only) + /// + [JsonProperty(PropertyName = "tokenUri")] + public string TokenUri { get; set; } + + /// + /// Gets or sets auth provider x509 certificate URL field of the API + /// key (write only) + /// + [JsonProperty(PropertyName = "authProviderX509CertUrl")] + public string AuthProviderX509CertUrl { get; set; } + + /// + /// Gets or sets client x509 certificate URL field of the API key + /// (write only) + /// + [JsonProperty(PropertyName = "clientX509CertUrl")] + public string ClientX509CertUrl { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (OrganizationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OrganizationId"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (ProjectId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ProjectId"); + } + if (PrivateKeyId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PrivateKeyId"); + } + if (PrivateKey == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PrivateKey"); + } + if (ClientEmail == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ClientEmail"); + } + if (ClientId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ClientId"); + } + if (AuthUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AuthUri"); + } + if (TokenUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TokenUri"); + } + if (AuthProviderX509CertUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AuthProviderX509CertUrl"); + } + if (ClientX509CertUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ClientX509CertUrl"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DMessagesNotInAllowedRange.cs index b4c92a0347b1..21b2e8bf7d9e 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of cloud to device messages (HTTP protocol) is not in allowed /// range. /// - [Newtonsoft.Json.JsonObject("HttpC2DMessagesNotInAllowedRange")] public partial class HttpC2DMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DRejectedMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DRejectedMessagesNotInAllowedRange.cs index a9d06f027578..73f69e0b71b0 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DRejectedMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpC2DRejectedMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of rejected cloud to device messages (HTTP protocol) is not in /// allowed range. /// - [Newtonsoft.Json.JsonObject("HttpC2DRejectedMessagesNotInAllowedRange")] public partial class HttpC2DRejectedMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpD2CMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpD2CMessagesNotInAllowedRange.cs index d9ecd22c241b..820edd41c00a 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpD2CMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HttpD2CMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of device to cloud messages (HTTP protocol) is not in allowed /// range. /// - [Newtonsoft.Json.JsonObject("HttpD2CMessagesNotInAllowedRange")] public partial class HttpD2CMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HybridComputeProvisioningState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HybridComputeProvisioningState.cs new file mode 100644 index 000000000000..738d7684264e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HybridComputeProvisioningState.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for HybridComputeProvisioningState. + /// + public static class HybridComputeProvisioningState + { + /// + /// Valid service principal details. + /// + public const string Valid = "Valid"; + /// + /// Invalid service principal details. + /// + public const string Invalid = "Invalid"; + /// + /// the service principal details are expired + /// + public const string Expired = "Expired"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HybridComputeSettingsProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HybridComputeSettingsProperties.cs new file mode 100644 index 000000000000..18bf12f00bc5 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/HybridComputeSettingsProperties.cs @@ -0,0 +1,124 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Settings for hybrid compute management + /// + public partial class HybridComputeSettingsProperties + { + /// + /// Initializes a new instance of the HybridComputeSettingsProperties + /// class. + /// + public HybridComputeSettingsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HybridComputeSettingsProperties + /// class. + /// + /// Whether or not to automatically install + /// Azure Arc (hybrid compute) agents on machines. Possible values + /// include: 'On', 'Off' + /// State of the service + /// principal and its secret. Possible values include: 'Valid', + /// 'Invalid', 'Expired' + /// The name of the resource group + /// where Arc (Hybrid Compute) connectors are connected. + /// The location where the metadata of machines + /// will be stored + /// For a non-Azure machine that is not + /// connected directly to the internet, specify a proxy server that the + /// non-Azure machine can use. + /// An object to access resources that + /// are secured by an Azure AD tenant. + public HybridComputeSettingsProperties(string autoProvision, string hybridComputeProvisioningState = default(string), string resourceGroupName = default(string), string region = default(string), ProxyServerProperties proxyServer = default(ProxyServerProperties), ServicePrincipalProperties servicePrincipal = default(ServicePrincipalProperties)) + { + HybridComputeProvisioningState = hybridComputeProvisioningState; + AutoProvision = autoProvision; + ResourceGroupName = resourceGroupName; + Region = region; + ProxyServer = proxyServer; + ServicePrincipal = servicePrincipal; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets state of the service principal and its secret. Possible values + /// include: 'Valid', 'Invalid', 'Expired' + /// + [JsonProperty(PropertyName = "hybridComputeProvisioningState")] + public string HybridComputeProvisioningState { get; private set; } + + /// + /// Gets or sets whether or not to automatically install Azure Arc + /// (hybrid compute) agents on machines. Possible values include: 'On', + /// 'Off' + /// + [JsonProperty(PropertyName = "autoProvision")] + public string AutoProvision { get; set; } + + /// + /// Gets or sets the name of the resource group where Arc (Hybrid + /// Compute) connectors are connected. + /// + [JsonProperty(PropertyName = "resourceGroupName")] + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets the location where the metadata of machines will be + /// stored + /// + [JsonProperty(PropertyName = "region")] + public string Region { get; set; } + + /// + /// Gets or sets for a non-Azure machine that is not connected directly + /// to the internet, specify a proxy server that the non-Azure machine + /// can use. + /// + [JsonProperty(PropertyName = "proxyServer")] + public ProxyServerProperties ProxyServer { get; set; } + + /// + /// Gets or sets an object to access resources that are secured by an + /// Azure AD tenant. + /// + [JsonProperty(PropertyName = "servicePrincipal")] + public ServicePrincipalProperties ServicePrincipal { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AutoProvision == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AutoProvision"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Intent.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Intent.cs new file mode 100644 index 000000000000..671f7b602390 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Intent.cs @@ -0,0 +1,117 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for Intent. + /// + public static class Intent + { + /// + /// Unknown + /// + public const string Unknown = "Unknown"; + /// + /// PreAttack could be either an attempt to access a certain resource + /// regardless of a malicious intent, or a failed attempt to gain + /// access to a target system to gather information prior to + /// exploitation. This step is usually detected as an attempt, + /// originating from outside the network, to scan the target system and + /// find a way in. Further details on the PreAttack stage can be read + /// in [MITRE Pre-Att&ck + /// matrix](https://attack.mitre.org/matrices/pre/). + /// + public const string PreAttack = "PreAttack"; + /// + /// InitialAccess is the stage where an attacker manages to get + /// foothold on the attacked resource. + /// + public const string InitialAccess = "InitialAccess"; + /// + /// Persistence is any access, action, or configuration change to a + /// system that gives a threat actor a persistent presence on that + /// system. + /// + public const string Persistence = "Persistence"; + /// + /// Privilege escalation is the result of actions that allow an + /// adversary to obtain a higher level of permissions on a system or + /// network. + /// + public const string PrivilegeEscalation = "PrivilegeEscalation"; + /// + /// Defense evasion consists of techniques an adversary may use to + /// evade detection or avoid other defenses. + /// + public const string DefenseEvasion = "DefenseEvasion"; + /// + /// Credential access represents techniques resulting in access to or + /// control over system, domain, or service credentials that are used + /// within an enterprise environment. + /// + public const string CredentialAccess = "CredentialAccess"; + /// + /// Discovery consists of techniques that allow the adversary to gain + /// knowledge about the system and internal network. + /// + public const string Discovery = "Discovery"; + /// + /// Lateral movement consists of techniques that enable an adversary to + /// access and control remote systems on a network and could, but does + /// not necessarily, include execution of tools on remote systems. + /// + public const string LateralMovement = "LateralMovement"; + /// + /// The execution tactic represents techniques that result in execution + /// of adversary-controlled code on a local or remote system. + /// + public const string Execution = "Execution"; + /// + /// Collection consists of techniques used to identify and gather + /// information, such as sensitive files, from a target network prior + /// to exfiltration. + /// + public const string Collection = "Collection"; + /// + /// Exfiltration refers to techniques and attributes that result or aid + /// in the adversary removing files and information from a target + /// network. + /// + public const string Exfiltration = "Exfiltration"; + /// + /// The command and control tactic represents how adversaries + /// communicate with systems under their control within a target + /// network. + /// + public const string CommandAndControl = "CommandAndControl"; + /// + /// Impact events primarily try to directly reduce the availability or + /// integrity of a system, service, or network; including manipulation + /// of data to impact a business or operational process. + /// + public const string Impact = "Impact"; + /// + /// Probing could be either an attempt to access a certain resource + /// regardless of a malicious intent, or a failed attempt to gain + /// access to a target system to gather information prior to + /// exploitation. + /// + public const string Probing = "Probing"; + /// + /// Exploitation is the stage where an attacker manages to get a + /// foothold on the attacked resource. This stage is relevant for + /// compute hosts and resources such as user accounts, certificates + /// etc. + /// + public const string Exploitation = "Exploitation"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IoTSecuritySolutionModel.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IoTSecuritySolutionModel.cs index 7a86a5e9c637..30c128604d47 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IoTSecuritySolutionModel.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IoTSecuritySolutionModel.cs @@ -34,7 +34,6 @@ public IoTSecuritySolutionModel() /// /// Initializes a new instance of the IoTSecuritySolutionModel class. /// - /// Workspace resource ID /// Resource display name. /// IoT Hub resource IDs /// Resource Id @@ -42,6 +41,7 @@ public IoTSecuritySolutionModel() /// Resource type /// Resource tags /// The resource location. + /// Workspace resource ID /// Status of the IoT Security solution. Possible /// values include: 'Enabled', 'Disabled' /// List of additional options for exporting to @@ -53,7 +53,7 @@ public IoTSecuritySolutionModel() /// solution. /// Unmasked IP address logging /// status. Possible values include: 'Disabled', 'Enabled' - public IoTSecuritySolutionModel(string workspace, string displayName, IList iotHubs, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string location = default(string), string status = default(string), IList export = default(IList), IList disabledDataSources = default(IList), UserDefinedResourcesProperties userDefinedResources = default(UserDefinedResourcesProperties), IList autoDiscoveredResources = default(IList), IList recommendationsConfiguration = default(IList), string unmaskedIpLoggingStatus = default(string)) + public IoTSecuritySolutionModel(string displayName, IList iotHubs, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string location = default(string), string workspace = default(string), string status = default(string), IList export = default(IList), IList disabledDataSources = default(IList), UserDefinedResourcesProperties userDefinedResources = default(UserDefinedResourcesProperties), IList autoDiscoveredResources = default(IList), IList recommendationsConfiguration = default(IList), string unmaskedIpLoggingStatus = default(string)) { Id = id; Name = name; @@ -179,10 +179,6 @@ public IoTSecuritySolutionModel() /// public virtual void Validate() { - if (Workspace == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Workspace"); - } if (DisplayName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "DisplayName"); diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlert.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlert.cs new file mode 100644 index 000000000000..03e3833029c3 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlert.cs @@ -0,0 +1,113 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// IoT alert + /// + [Rest.Serialization.JsonTransformation] + public partial class IotAlert + { + /// + /// Initializes a new instance of the IotAlert class. + /// + public IotAlert() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotAlert class. + /// + /// Holds the product canonical identifier + /// of the alert within the scope of a product + /// Display name of the main entity + /// being reported on + /// The type name of the alert + /// The impact start time of the alert (the + /// time of the first event or activity included in the alert) + /// The impact end time of the alert (the time + /// of the last event or activity included in the alert) + /// A list of entities related to the + /// alert + /// A bag of fields which extends the + /// alert information + public IotAlert(string systemAlertId = default(string), string compromisedEntity = default(string), string alertType = default(string), string startTimeUtc = default(string), string endTimeUtc = default(string), IList entities = default(IList), object extendedProperties = default(object)) + { + SystemAlertId = systemAlertId; + CompromisedEntity = compromisedEntity; + AlertType = alertType; + StartTimeUtc = startTimeUtc; + EndTimeUtc = endTimeUtc; + Entities = entities; + ExtendedProperties = extendedProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets holds the product canonical identifier of the alert within the + /// scope of a product + /// + [JsonProperty(PropertyName = "properties.systemAlertId")] + public string SystemAlertId { get; private set; } + + /// + /// Gets display name of the main entity being reported on + /// + [JsonProperty(PropertyName = "properties.compromisedEntity")] + public string CompromisedEntity { get; private set; } + + /// + /// Gets the type name of the alert + /// + [JsonProperty(PropertyName = "properties.alertType")] + public string AlertType { get; private set; } + + /// + /// Gets the impact start time of the alert (the time of the first + /// event or activity included in the alert) + /// + [JsonProperty(PropertyName = "properties.startTimeUtc")] + public string StartTimeUtc { get; private set; } + + /// + /// Gets the impact end time of the alert (the time of the last event + /// or activity included in the alert) + /// + [JsonProperty(PropertyName = "properties.endTimeUtc")] + public string EndTimeUtc { get; private set; } + + /// + /// Gets or sets a list of entities related to the alert + /// + [JsonProperty(PropertyName = "properties.entities")] + public IList Entities { get; set; } + + /// + /// Gets or sets a bag of fields which extends the alert information + /// + [JsonProperty(PropertyName = "properties.extendedProperties")] + public object ExtendedProperties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertModel.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertModel.cs new file mode 100644 index 000000000000..d1555b4f7452 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertModel.cs @@ -0,0 +1,113 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// IoT alert + /// + [Rest.Serialization.JsonTransformation] + public partial class IotAlertModel + { + /// + /// Initializes a new instance of the IotAlertModel class. + /// + public IotAlertModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotAlertModel class. + /// + /// Holds the product canonical identifier + /// of the alert within the scope of a product + /// Display name of the main entity + /// being reported on + /// The type name of the alert + /// The impact start time of the alert (the + /// time of the first event or activity included in the alert) + /// The impact end time of the alert (the time + /// of the last event or activity included in the alert) + /// A list of entities related to the + /// alert + /// A bag of fields which extends the + /// alert information + public IotAlertModel(string systemAlertId = default(string), string compromisedEntity = default(string), string alertType = default(string), string startTimeUtc = default(string), string endTimeUtc = default(string), IList entities = default(IList), object extendedProperties = default(object)) + { + SystemAlertId = systemAlertId; + CompromisedEntity = compromisedEntity; + AlertType = alertType; + StartTimeUtc = startTimeUtc; + EndTimeUtc = endTimeUtc; + Entities = entities; + ExtendedProperties = extendedProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets holds the product canonical identifier of the alert within the + /// scope of a product + /// + [JsonProperty(PropertyName = "properties.systemAlertId")] + public string SystemAlertId { get; private set; } + + /// + /// Gets display name of the main entity being reported on + /// + [JsonProperty(PropertyName = "properties.compromisedEntity")] + public string CompromisedEntity { get; private set; } + + /// + /// Gets the type name of the alert + /// + [JsonProperty(PropertyName = "properties.alertType")] + public string AlertType { get; private set; } + + /// + /// Gets the impact start time of the alert (the time of the first + /// event or activity included in the alert) + /// + [JsonProperty(PropertyName = "properties.startTimeUtc")] + public string StartTimeUtc { get; private set; } + + /// + /// Gets the impact end time of the alert (the time of the last event + /// or activity included in the alert) + /// + [JsonProperty(PropertyName = "properties.endTimeUtc")] + public string EndTimeUtc { get; private set; } + + /// + /// Gets or sets a list of entities related to the alert + /// + [JsonProperty(PropertyName = "properties.entities")] + public IList Entities { get; set; } + + /// + /// Gets or sets a bag of fields which extends the alert information + /// + [JsonProperty(PropertyName = "properties.extendedProperties")] + public object ExtendedProperties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertType.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertType.cs new file mode 100644 index 000000000000..bfc9317b2794 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertType.cs @@ -0,0 +1,146 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// IoT alert type. + /// + [Rest.Serialization.JsonTransformation] + public partial class IotAlertType : Resource + { + /// + /// Initializes a new instance of the IotAlertType class. + /// + public IotAlertType() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotAlertType class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// The display name of the + /// alert + /// The severity of the alert. Possible values + /// include: 'Informational', 'Low', 'Medium', 'High' + /// Description of the suspected + /// vulnerability and meaning. + /// The name of the alert provider or + /// internal partner + /// The name of the product which published + /// this alert + /// The name of a component inside + /// the product which generated the alert + /// The name of the vendor that raise the + /// alert + /// Kill chain related intent behind the alert. + /// Could contain multiple enum values (separated by commas). Possible + /// values include: 'Unknown', 'PreAttack', 'InitialAccess', + /// 'Persistence', 'PrivilegeEscalation', 'DefenseEvasion', + /// 'CredentialAccess', 'Discovery', 'LateralMovement', 'Execution', + /// 'Collection', 'Exfiltration', 'CommandAndControl', 'Impact', + /// 'Probing', 'Exploitation' + /// Manual action items to take to + /// remediate the alert + public IotAlertType(string id = default(string), string name = default(string), string type = default(string), string alertDisplayName = default(string), string severity = default(string), string description = default(string), string providerName = default(string), string productName = default(string), string productComponentName = default(string), string vendorName = default(string), string intent = default(string), IList remediationSteps = default(IList)) + : base(id, name, type) + { + AlertDisplayName = alertDisplayName; + Severity = severity; + Description = description; + ProviderName = providerName; + ProductName = productName; + ProductComponentName = productComponentName; + VendorName = vendorName; + Intent = intent; + RemediationSteps = remediationSteps; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the display name of the alert + /// + [JsonProperty(PropertyName = "properties.alertDisplayName")] + public string AlertDisplayName { get; private set; } + + /// + /// Gets the severity of the alert. Possible values include: + /// 'Informational', 'Low', 'Medium', 'High' + /// + [JsonProperty(PropertyName = "properties.severity")] + public string Severity { get; private set; } + + /// + /// Gets description of the suspected vulnerability and meaning. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets the name of the alert provider or internal partner + /// + [JsonProperty(PropertyName = "properties.providerName")] + public string ProviderName { get; private set; } + + /// + /// Gets the name of the product which published this alert + /// + [JsonProperty(PropertyName = "properties.productName")] + public string ProductName { get; private set; } + + /// + /// Gets the name of a component inside the product which generated the + /// alert + /// + [JsonProperty(PropertyName = "properties.productComponentName")] + public string ProductComponentName { get; private set; } + + /// + /// Gets the name of the vendor that raise the alert + /// + [JsonProperty(PropertyName = "properties.vendorName")] + public string VendorName { get; private set; } + + /// + /// Gets kill chain related intent behind the alert. Could contain + /// multiple enum values (separated by commas). Possible values + /// include: 'Unknown', 'PreAttack', 'InitialAccess', 'Persistence', + /// 'PrivilegeEscalation', 'DefenseEvasion', 'CredentialAccess', + /// 'Discovery', 'LateralMovement', 'Execution', 'Collection', + /// 'Exfiltration', 'CommandAndControl', 'Impact', 'Probing', + /// 'Exploitation' + /// + [JsonProperty(PropertyName = "properties.intent")] + public string Intent { get; private set; } + + /// + /// Gets manual action items to take to remediate the alert + /// + [JsonProperty(PropertyName = "properties.remediationSteps")] + public IList RemediationSteps { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertTypeList.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertTypeList.cs new file mode 100644 index 000000000000..2ebee5a098f9 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotAlertTypeList.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of alert types + /// + public partial class IotAlertTypeList + { + /// + /// Initializes a new instance of the IotAlertTypeList class. + /// + public IotAlertTypeList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotAlertTypeList class. + /// + /// List data + public IotAlertTypeList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list data + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotDefenderSettingsList.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotDefenderSettingsList.cs new file mode 100644 index 000000000000..43b7a5c0d4ed --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotDefenderSettingsList.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of IoT Defender settings + /// + public partial class IotDefenderSettingsList + { + /// + /// Initializes a new instance of the IotDefenderSettingsList class. + /// + public IotDefenderSettingsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotDefenderSettingsList class. + /// + /// List data + public IotDefenderSettingsList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list data + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotDefenderSettingsModel.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotDefenderSettingsModel.cs new file mode 100644 index 000000000000..75daffa95c3c --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotDefenderSettingsModel.cs @@ -0,0 +1,89 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// IoT Defender settings + /// + [Rest.Serialization.JsonTransformation] + public partial class IotDefenderSettingsModel : Resource + { + /// + /// Initializes a new instance of the IotDefenderSettingsModel class. + /// + public IotDefenderSettingsModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotDefenderSettingsModel class. + /// + /// Size of the device quota (as a opposed to + /// a Pay as You Go billing model). Value is required to be in + /// multiples of 1000. + /// Sentinel Workspace + /// Resource Ids + /// Resource Id + /// Resource name + /// Resource type + public IotDefenderSettingsModel(int deviceQuota, IList sentinelWorkspaceResourceIds, string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + DeviceQuota = deviceQuota; + SentinelWorkspaceResourceIds = sentinelWorkspaceResourceIds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets size of the device quota (as a opposed to a Pay as You + /// Go billing model). Value is required to be in multiples of 1000. + /// + [JsonProperty(PropertyName = "properties.deviceQuota")] + public int DeviceQuota { get; set; } + + /// + /// Gets or sets sentinel Workspace Resource Ids + /// + [JsonProperty(PropertyName = "properties.sentinelWorkspaceResourceIds")] + public IList SentinelWorkspaceResourceIds { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SentinelWorkspaceResourceIds == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SentinelWorkspaceResourceIds"); + } + if (DeviceQuota < 1000) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "DeviceQuota", 1000); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendation.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendation.cs new file mode 100644 index 000000000000..c535de1be9c0 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendation.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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// IoT recommendation + /// + [Rest.Serialization.JsonTransformation] + public partial class IotRecommendation : Resource + { + /// + /// Initializes a new instance of the IotRecommendation class. + /// + public IotRecommendation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotRecommendation class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// Identifier of the device being reported + /// on + /// The type name of the + /// recommendation + /// The discovery time of the + /// recommendation + /// A bag of fields which + /// extends the recommendation information + public IotRecommendation(string id = default(string), string name = default(string), string type = default(string), string deviceId = default(string), string recommendationType = default(string), string discoveredTimeUtc = default(string), object recommendationAdditionalData = default(object)) + : base(id, name, type) + { + DeviceId = deviceId; + RecommendationType = recommendationType; + DiscoveredTimeUtc = discoveredTimeUtc; + RecommendationAdditionalData = recommendationAdditionalData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets identifier of the device being reported on + /// + [JsonProperty(PropertyName = "properties.deviceId")] + public string DeviceId { get; private set; } + + /// + /// Gets the type name of the recommendation + /// + [JsonProperty(PropertyName = "properties.recommendationType")] + public string RecommendationType { get; private set; } + + /// + /// Gets the discovery time of the recommendation + /// + [JsonProperty(PropertyName = "properties.discoveredTimeUtc")] + public string DiscoveredTimeUtc { get; private set; } + + /// + /// Gets or sets a bag of fields which extends the recommendation + /// information + /// + [JsonProperty(PropertyName = "properties.recommendationAdditionalData")] + public object RecommendationAdditionalData { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationModel.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationModel.cs new file mode 100644 index 000000000000..f59146eb9a03 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationModel.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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// IoT recommendation + /// + [Rest.Serialization.JsonTransformation] + public partial class IotRecommendationModel : Resource + { + /// + /// Initializes a new instance of the IotRecommendationModel class. + /// + public IotRecommendationModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotRecommendationModel class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// Identifier of the device being reported + /// on + /// The type name of the + /// recommendation + /// The discovery time of the + /// recommendation + /// A bag of fields which + /// extends the recommendation information + public IotRecommendationModel(string id = default(string), string name = default(string), string type = default(string), string deviceId = default(string), string recommendationType = default(string), string discoveredTimeUtc = default(string), object recommendationAdditionalData = default(object)) + : base(id, name, type) + { + DeviceId = deviceId; + RecommendationType = recommendationType; + DiscoveredTimeUtc = discoveredTimeUtc; + RecommendationAdditionalData = recommendationAdditionalData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets identifier of the device being reported on + /// + [JsonProperty(PropertyName = "properties.deviceId")] + public string DeviceId { get; private set; } + + /// + /// Gets the type name of the recommendation + /// + [JsonProperty(PropertyName = "properties.recommendationType")] + public string RecommendationType { get; private set; } + + /// + /// Gets the discovery time of the recommendation + /// + [JsonProperty(PropertyName = "properties.discoveredTimeUtc")] + public string DiscoveredTimeUtc { get; private set; } + + /// + /// Gets or sets a bag of fields which extends the recommendation + /// information + /// + [JsonProperty(PropertyName = "properties.recommendationAdditionalData")] + public object RecommendationAdditionalData { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationType.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationType.cs new file mode 100644 index 000000000000..8cc99a60a9bd --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationType.cs @@ -0,0 +1,136 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// IoT recommendation type. + /// + [Rest.Serialization.JsonTransformation] + public partial class IotRecommendationType : Resource + { + /// + /// Initializes a new instance of the IotRecommendationType class. + /// + public IotRecommendationType() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotRecommendationType class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// The display name of the + /// recommendation + /// The severity of the recommendation. Possible + /// values include: 'Unknown', 'NotApplicable', 'Healthy', + /// 'OffByPolicy', 'Low', 'Medium', 'High' + /// Description of the suspected + /// vulnerability and meaning. + /// The name of the product which published + /// this recommendation + /// The name of a component inside + /// the product which generated the recommendation + /// The name of the vendor that raised the + /// recommendation + /// The name of the recommendation's control + /// category + /// Manual action items to take to + /// resolve the recommendation + /// The alert's data source + public IotRecommendationType(string id = default(string), string name = default(string), string type = default(string), string recommendationDisplayName = default(string), string severity = default(string), string description = default(string), string productName = default(string), string productComponentName = default(string), string vendorName = default(string), string control = default(string), IList remediationSteps = default(IList), string dataSource = default(string)) + : base(id, name, type) + { + RecommendationDisplayName = recommendationDisplayName; + Severity = severity; + Description = description; + ProductName = productName; + ProductComponentName = productComponentName; + VendorName = vendorName; + Control = control; + RemediationSteps = remediationSteps; + DataSource = dataSource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the display name of the recommendation + /// + [JsonProperty(PropertyName = "properties.recommendationDisplayName")] + public string RecommendationDisplayName { get; private set; } + + /// + /// Gets the severity of the recommendation. Possible values include: + /// 'Unknown', 'NotApplicable', 'Healthy', 'OffByPolicy', 'Low', + /// 'Medium', 'High' + /// + [JsonProperty(PropertyName = "properties.severity")] + public string Severity { get; private set; } + + /// + /// Gets description of the suspected vulnerability and meaning. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets the name of the product which published this recommendation + /// + [JsonProperty(PropertyName = "properties.productName")] + public string ProductName { get; private set; } + + /// + /// Gets the name of a component inside the product which generated the + /// recommendation + /// + [JsonProperty(PropertyName = "properties.productComponentName")] + public string ProductComponentName { get; private set; } + + /// + /// Gets the name of the vendor that raised the recommendation + /// + [JsonProperty(PropertyName = "properties.vendorName")] + public string VendorName { get; private set; } + + /// + /// Gets the name of the recommendation's control category + /// + [JsonProperty(PropertyName = "properties.control")] + public string Control { get; private set; } + + /// + /// Gets manual action items to take to resolve the recommendation + /// + [JsonProperty(PropertyName = "properties.remediationSteps")] + public IList RemediationSteps { get; private set; } + + /// + /// Gets the alert's data source + /// + [JsonProperty(PropertyName = "properties.dataSource")] + public string DataSource { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationTypeList.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationTypeList.cs new file mode 100644 index 000000000000..d2681eedc651 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotRecommendationTypeList.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of recommendation types + /// + public partial class IotRecommendationTypeList + { + /// + /// Initializes a new instance of the IotRecommendationTypeList class. + /// + public IotRecommendationTypeList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotRecommendationTypeList class. + /// + /// List data + public IotRecommendationTypeList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list data + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotSensor.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotSensor.cs new file mode 100644 index 000000000000..a78e65a6ae6b --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotSensor.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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// IoT sensor + /// + public partial class IotSensor : Resource + { + /// + /// Initializes a new instance of the IotSensor class. + /// + public IotSensor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotSensor class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// IoT sensor properties + public IotSensor(string id = default(string), string name = default(string), string type = default(string), object properties = default(object)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets ioT sensor properties + /// + [JsonProperty(PropertyName = "properties")] + public object Properties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotSensorsList.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotSensorsList.cs new file mode 100644 index 000000000000..aac5bc83d934 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IotSensorsList.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of IoT sensors + /// + public partial class IotSensorsList + { + /// + /// Initializes a new instance of the IotSensorsList class. + /// + public IotSensorsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotSensorsList class. + /// + /// List data + public IotSensorsList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list data + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IpAddress.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IpAddress.cs new file mode 100644 index 000000000000..816fa1f54c92 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/IpAddress.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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// IP Address information + /// + public partial class IpAddress + { + /// + /// Initializes a new instance of the IpAddress class. + /// + public IpAddress() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IpAddress class. + /// + /// IPV4 address + /// Detection time of the ip + /// address. + /// Subnet Classless Inter-Domain + /// Routing + /// Fully qualified domain name + /// FQDN last lookup time. + public IpAddress(string v4Address = default(string), System.DateTime? detectionTime = default(System.DateTime?), string subnetCidr = default(string), string fqdn = default(string), System.DateTime? fqdnLastLookupTime = default(System.DateTime?)) + { + V4Address = v4Address; + DetectionTime = detectionTime; + SubnetCidr = subnetCidr; + Fqdn = fqdn; + FqdnLastLookupTime = fqdnLastLookupTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets IPV4 address + /// + [JsonProperty(PropertyName = "v4Address")] + public string V4Address { get; private set; } + + /// + /// Gets detection time of the ip address. + /// + [JsonProperty(PropertyName = "detectionTime")] + public System.DateTime? DetectionTime { get; private set; } + + /// + /// Gets subnet Classless Inter-Domain Routing + /// + [JsonProperty(PropertyName = "subnetCidr")] + public string SubnetCidr { get; private set; } + + /// + /// Gets fully qualified domain name + /// + [JsonProperty(PropertyName = "fqdn")] + public string Fqdn { get; private set; } + + /// + /// Gets FQDN last lookup time. + /// + [JsonProperty(PropertyName = "fqdnLastLookupTime")] + public System.DateTime? FqdnLastLookupTime { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ListCustomAlertRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ListCustomAlertRule.cs index 763959ad3860..528d183316de 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ListCustomAlertRule.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ListCustomAlertRule.cs @@ -16,7 +16,6 @@ namespace Microsoft.Azure.Management.Security.Models /// /// A List custom alert rule. /// - [Newtonsoft.Json.JsonObject("ListCustomAlertRule")] public partial class ListCustomAlertRule : CustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LocalUserNotAllowed.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LocalUserNotAllowed.cs index 27e661e467c1..0005bd059e44 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LocalUserNotAllowed.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LocalUserNotAllowed.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -19,7 +18,6 @@ namespace Microsoft.Azure.Management.Security.Models /// Login by a local user that isn't allowed. Allow list consists of login /// names to allow. /// - [Newtonsoft.Json.JsonObject("LocalUserNotAllowed")] public partial class LocalUserNotAllowed : AllowlistCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LogAnalyticsIdentifier.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LogAnalyticsIdentifier.cs new file mode 100644 index 000000000000..75b4efedb02b --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/LogAnalyticsIdentifier.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a Log Analytics workspace scope identifier. + /// + [Newtonsoft.Json.JsonObject("LogAnalytics")] + public partial class LogAnalyticsIdentifier : ResourceIdentifier + { + /// + /// Initializes a new instance of the LogAnalyticsIdentifier class. + /// + public LogAnalyticsIdentifier() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogAnalyticsIdentifier class. + /// + /// The LogAnalytics workspace id that stores + /// this alert. + /// The azure subscription id for + /// the LogAnalytics workspace storing this alert. + /// The azure resource group for + /// the LogAnalytics workspace storing this alert + /// (optional) The LogAnalytics agent id + /// reporting the event that this alert is based on. + public LogAnalyticsIdentifier(string workspaceId = default(string), string workspaceSubscriptionId = default(string), string workspaceResourceGroup = default(string), string agentId = default(string)) + { + WorkspaceId = workspaceId; + WorkspaceSubscriptionId = workspaceSubscriptionId; + WorkspaceResourceGroup = workspaceResourceGroup; + AgentId = agentId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the LogAnalytics workspace id that stores this alert. + /// + [JsonProperty(PropertyName = "workspaceId")] + public string WorkspaceId { get; private set; } + + /// + /// Gets the azure subscription id for the LogAnalytics workspace + /// storing this alert. + /// + [JsonProperty(PropertyName = "workspaceSubscriptionId")] + public string WorkspaceSubscriptionId { get; private set; } + + /// + /// Gets the azure resource group for the LogAnalytics workspace + /// storing this alert + /// + [JsonProperty(PropertyName = "workspaceResourceGroup")] + public string WorkspaceResourceGroup { get; private set; } + + /// + /// Gets (optional) The LogAnalytics agent id reporting the event that + /// this alert is based on. + /// + [JsonProperty(PropertyName = "agentId")] + public string AgentId { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (WorkspaceSubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(WorkspaceSubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "WorkspaceSubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MacAddress.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MacAddress.cs new file mode 100644 index 000000000000..94fcbc2b4946 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MacAddress.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// MAC Address information + /// + public partial class MacAddress + { + /// + /// Initializes a new instance of the MacAddress class. + /// + public MacAddress() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MacAddress class. + /// + /// MAC address + /// Detection time of the mac + /// address. + /// Indicates whether this is the primary + /// secondary MAC address of the device. Possible values include: + /// 'Primary', 'Secondary' + /// Indicates whether the relation of + /// the mac to the ip address is certain or a guess. Possible values + /// include: 'Guess', 'Certain' + public MacAddress(string address = default(string), System.DateTime? detectionTime = default(System.DateTime?), string significance = default(string), string relationToIpStatus = default(string)) + { + Address = address; + DetectionTime = detectionTime; + Significance = significance; + RelationToIpStatus = relationToIpStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets MAC address + /// + [JsonProperty(PropertyName = "address")] + public string Address { get; private set; } + + /// + /// Gets detection time of the mac address. + /// + [JsonProperty(PropertyName = "detectionTime")] + public System.DateTime? DetectionTime { get; private set; } + + /// + /// Gets indicates whether this is the primary secondary MAC address of + /// the device. Possible values include: 'Primary', 'Secondary' + /// + [JsonProperty(PropertyName = "significance")] + public string Significance { get; private set; } + + /// + /// Gets indicates whether the relation of the mac to the ip address is + /// certain or a guess. Possible values include: 'Guess', 'Certain' + /// + [JsonProperty(PropertyName = "relationToIpStatus")] + public string RelationToIpStatus { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MacSignificance.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MacSignificance.cs new file mode 100644 index 000000000000..5941e418045b --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MacSignificance.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.Security.Models +{ + + /// + /// Defines values for MacSignificance. + /// + public static class MacSignificance + { + public const string Primary = "Primary"; + public const string Secondary = "Secondary"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ManagementState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ManagementState.cs new file mode 100644 index 000000000000..8185b78777e1 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ManagementState.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.Security.Models +{ + + /// + /// Defines values for ManagementState. + /// + public static class ManagementState + { + public const string Managed = "Managed"; + public const string Unmanaged = "Unmanaged"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DMessagesNotInAllowedRange.cs index 50ce5fe30a68..3df534833527 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of cloud to device messages (MQTT protocol) is not in allowed /// range. /// - [Newtonsoft.Json.JsonObject("MqttC2DMessagesNotInAllowedRange")] public partial class MqttC2DMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DRejectedMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DRejectedMessagesNotInAllowedRange.cs index 55fb3039b11a..6607cb5285c9 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DRejectedMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttC2DRejectedMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of rejected cloud to device messages (MQTT protocol) is not in /// allowed range. /// - [Newtonsoft.Json.JsonObject("MqttC2DRejectedMessagesNotInAllowedRange")] public partial class MqttC2DRejectedMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttD2CMessagesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttD2CMessagesNotInAllowedRange.cs index 358bb0c6e4f8..1bba936ed591 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttD2CMessagesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/MqttD2CMessagesNotInAllowedRange.cs @@ -10,14 +10,12 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of device to cloud messages (MQTT protocol) is not in allowed /// range. /// - [Newtonsoft.Json.JsonObject("MqttD2CMessagesNotInAllowedRange")] public partial class MqttD2CMessagesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/NetworkInterface.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/NetworkInterface.cs new file mode 100644 index 000000000000..054c4b49fc35 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/NetworkInterface.cs @@ -0,0 +1,65 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network interface + /// + public partial class NetworkInterface + { + /// + /// Initializes a new instance of the NetworkInterface class. + /// + public NetworkInterface() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkInterface class. + /// + /// List of device vlans. + public NetworkInterface(IpAddress ipAddress = default(IpAddress), MacAddress macAddress = default(MacAddress), IList vlans = default(IList)) + { + IpAddress = ipAddress; + MacAddress = macAddress; + Vlans = vlans; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "ipAddress")] + public IpAddress IpAddress { get; set; } + + /// + /// + [JsonProperty(PropertyName = "macAddress")] + public MacAddress MacAddress { get; set; } + + /// + /// Gets list of device vlans. + /// + [JsonProperty(PropertyName = "vlans")] + public IList Vlans { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseIotSensor.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseIotSensor.cs new file mode 100644 index 000000000000..da0ef2cc817f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseIotSensor.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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// On-premise IoT sensor + /// + public partial class OnPremiseIotSensor : Resource + { + /// + /// Initializes a new instance of the OnPremiseIotSensor class. + /// + public OnPremiseIotSensor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OnPremiseIotSensor class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// On-premise IoT sensor properties + public OnPremiseIotSensor(string id = default(string), string name = default(string), string type = default(string), object properties = default(object)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets on-premise IoT sensor properties + /// + [JsonProperty(PropertyName = "properties")] + public object Properties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseIotSensorsList.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseIotSensorsList.cs new file mode 100644 index 000000000000..894a64a8ed83 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseIotSensorsList.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of on-premise IoT sensors + /// + public partial class OnPremiseIotSensorsList + { + /// + /// Initializes a new instance of the OnPremiseIotSensorsList class. + /// + public OnPremiseIotSensorsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OnPremiseIotSensorsList class. + /// + /// List data + public OnPremiseIotSensorsList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list data + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseSqlResourceDetails.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseSqlResourceDetails.cs new file mode 100644 index 000000000000..084f5df0f1b6 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/OnPremiseSqlResourceDetails.cs @@ -0,0 +1,90 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of the On Premise Sql resource that was assessed + /// + [Newtonsoft.Json.JsonObject("OnPremiseSql")] + public partial class OnPremiseSqlResourceDetails : OnPremiseResourceDetails + { + /// + /// Initializes a new instance of the OnPremiseSqlResourceDetails + /// class. + /// + public OnPremiseSqlResourceDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OnPremiseSqlResourceDetails + /// class. + /// + /// Azure resource Id of the workspace the + /// machine is attached to + /// The unique Id of the machine + /// The oms agent Id installed on the + /// machine + /// The name of the machine + /// The Sql server name installed on the + /// machine + /// The Sql database name installed on the + /// machine + public OnPremiseSqlResourceDetails(string workspaceId, string vmuuid, string sourceComputerId, string machineName, string serverName, string databaseName) + : base(workspaceId, vmuuid, sourceComputerId, machineName) + { + ServerName = serverName; + DatabaseName = databaseName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Sql server name installed on the machine + /// + [JsonProperty(PropertyName = "serverName")] + public string ServerName { get; set; } + + /// + /// Gets or sets the Sql database name installed on the machine + /// + [JsonProperty(PropertyName = "databaseName")] + public string DatabaseName { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (ServerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ServerName"); + } + if (DatabaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DatabaseName"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadInfo.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadInfo.cs new file mode 100644 index 000000000000..42a89b6b7df2 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadInfo.cs @@ -0,0 +1,69 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information on a specific package download + /// + public partial class PackageDownloadInfo + { + /// + /// Initializes a new instance of the PackageDownloadInfo class. + /// + public PackageDownloadInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PackageDownloadInfo class. + /// + /// Version number + /// Download link + /// Kind of the version. Possible values + /// include: 'Latest', 'Previous', 'Preview' + public PackageDownloadInfo(string version = default(string), string link = default(string), string versionKind = default(string)) + { + Version = version; + Link = link; + VersionKind = versionKind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets version number + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; private set; } + + /// + /// Gets or sets download link + /// + [JsonProperty(PropertyName = "link")] + public string Link { get; set; } + + /// + /// Gets kind of the version. Possible values include: 'Latest', + /// 'Previous', 'Preview' + /// + [JsonProperty(PropertyName = "versionKind")] + public string VersionKind { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloads.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloads.cs new file mode 100644 index 000000000000..fc5f9bb7fc97 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloads.cs @@ -0,0 +1,69 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information about package downloads + /// + public partial class PackageDownloads + { + /// + /// Initializes a new instance of the PackageDownloads class. + /// + public PackageDownloads() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PackageDownloads class. + /// + /// Contains all Sensor binary downloads + /// All downloads for Central + /// Manager + /// All downloads for threat + /// intelligence + public PackageDownloads(PackageDownloadsSensor sensor = default(PackageDownloadsSensor), PackageDownloadsCentralManager centralManager = default(PackageDownloadsCentralManager), PackageDownloadsThreatIntelligence threatIntelligence = default(PackageDownloadsThreatIntelligence)) + { + Sensor = sensor; + CentralManager = centralManager; + ThreatIntelligence = threatIntelligence; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets contains all Sensor binary downloads + /// + [JsonProperty(PropertyName = "sensor")] + public PackageDownloadsSensor Sensor { get; private set; } + + /// + /// Gets all downloads for Central Manager + /// + [JsonProperty(PropertyName = "centralManager")] + public PackageDownloadsCentralManager CentralManager { get; private set; } + + /// + /// Gets all downloads for threat intelligence + /// + [JsonProperty(PropertyName = "threatIntelligence")] + public PackageDownloadsThreatIntelligence ThreatIntelligence { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManager.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManager.cs new file mode 100644 index 000000000000..f2172606f5e2 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManager.cs @@ -0,0 +1,65 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// All downloads for Central Manager + /// + public partial class PackageDownloadsCentralManager + { + /// + /// Initializes a new instance of the PackageDownloadsCentralManager + /// class. + /// + public PackageDownloadsCentralManager() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PackageDownloadsCentralManager + /// class. + /// + /// Contains full package downloads + /// Central Manager upgrade package downloads (on + /// existing installations) + public PackageDownloadsCentralManager(PackageDownloadsCentralManagerFull full = default(PackageDownloadsCentralManagerFull), IList upgrade = default(IList)) + { + Full = full; + Upgrade = upgrade; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets contains full package downloads + /// + [JsonProperty(PropertyName = "full")] + public PackageDownloadsCentralManagerFull Full { get; private set; } + + /// + /// Gets central Manager upgrade package downloads (on existing + /// installations) + /// + [JsonProperty(PropertyName = "upgrade")] + public IList Upgrade { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManagerFull.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManagerFull.cs new file mode 100644 index 000000000000..5243cc8a5712 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManagerFull.cs @@ -0,0 +1,66 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Contains full package downloads + /// + public partial class PackageDownloadsCentralManagerFull + { + /// + /// Initializes a new instance of the + /// PackageDownloadsCentralManagerFull class. + /// + public PackageDownloadsCentralManagerFull() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PackageDownloadsCentralManagerFull class. + /// + /// Contains all ISO full versions of the Central + /// Manager + /// Contains all OVF (virtual machine) full versions + /// of the Central Manager + public PackageDownloadsCentralManagerFull(IList iso = default(IList), PackageDownloadsCentralManagerFullOvf ovf = default(PackageDownloadsCentralManagerFullOvf)) + { + Iso = iso; + Ovf = ovf; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets contains all ISO full versions of the Central Manager + /// + [JsonProperty(PropertyName = "iso")] + public IList Iso { get; private set; } + + /// + /// Gets contains all OVF (virtual machine) full versions of the + /// Central Manager + /// + [JsonProperty(PropertyName = "ovf")] + public PackageDownloadsCentralManagerFullOvf Ovf { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManagerFullOvf.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManagerFullOvf.cs new file mode 100644 index 000000000000..d16c6b7b3d3f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsCentralManagerFullOvf.cs @@ -0,0 +1,81 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Contains all OVF (virtual machine) full versions of the Central Manager + /// + public partial class PackageDownloadsCentralManagerFullOvf + { + /// + /// Initializes a new instance of the + /// PackageDownloadsCentralManagerFullOvf class. + /// + public PackageDownloadsCentralManagerFullOvf() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PackageDownloadsCentralManagerFullOvf class. + /// + /// The Enterprise package type + /// The + /// EnterpriseHighAvailability package type + /// The Medium package type + /// The MediumHighAvailability + /// package type + public PackageDownloadsCentralManagerFullOvf(IList enterprise = default(IList), IList enterpriseHighAvailability = default(IList), IList medium = default(IList), IList mediumHighAvailability = default(IList)) + { + Enterprise = enterprise; + EnterpriseHighAvailability = enterpriseHighAvailability; + Medium = medium; + MediumHighAvailability = mediumHighAvailability; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the Enterprise package type + /// + [JsonProperty(PropertyName = "enterprise")] + public IList Enterprise { get; private set; } + + /// + /// Gets the EnterpriseHighAvailability package type + /// + [JsonProperty(PropertyName = "enterpriseHighAvailability")] + public IList EnterpriseHighAvailability { get; private set; } + + /// + /// Gets the Medium package type + /// + [JsonProperty(PropertyName = "medium")] + public IList Medium { get; private set; } + + /// + /// Gets the MediumHighAvailability package type + /// + [JsonProperty(PropertyName = "mediumHighAvailability")] + public IList MediumHighAvailability { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensor.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensor.cs new file mode 100644 index 000000000000..06a65fb7899c --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensor.cs @@ -0,0 +1,63 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Contains all Sensor binary downloads + /// + public partial class PackageDownloadsSensor + { + /// + /// Initializes a new instance of the PackageDownloadsSensor class. + /// + public PackageDownloadsSensor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PackageDownloadsSensor class. + /// + /// Contains full package downloads + /// Sensor upgrade package downloads (on existing + /// installations) + public PackageDownloadsSensor(PackageDownloadsSensorFull full = default(PackageDownloadsSensorFull), IList upgrade = default(IList)) + { + Full = full; + Upgrade = upgrade; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets contains full package downloads + /// + [JsonProperty(PropertyName = "full")] + public PackageDownloadsSensorFull Full { get; private set; } + + /// + /// Gets or sets sensor upgrade package downloads (on existing + /// installations) + /// + [JsonProperty(PropertyName = "upgrade")] + public IList Upgrade { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensorFull.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensorFull.cs new file mode 100644 index 000000000000..3f5f6aee3a49 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensorFull.cs @@ -0,0 +1,64 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Contains full package downloads + /// + public partial class PackageDownloadsSensorFull + { + /// + /// Initializes a new instance of the PackageDownloadsSensorFull class. + /// + public PackageDownloadsSensorFull() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PackageDownloadsSensorFull class. + /// + /// Contains all ISO full versions for the + /// sensor + /// Contains all OVF (virtual machine) full versions + /// for the sensor + public PackageDownloadsSensorFull(IList iso = default(IList), PackageDownloadsSensorFullOvf ovf = default(PackageDownloadsSensorFullOvf)) + { + Iso = iso; + Ovf = ovf; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets contains all ISO full versions for the sensor + /// + [JsonProperty(PropertyName = "iso")] + public IList Iso { get; private set; } + + /// + /// Gets or sets contains all OVF (virtual machine) full versions for + /// the sensor + /// + [JsonProperty(PropertyName = "ovf")] + public PackageDownloadsSensorFullOvf Ovf { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensorFullOvf.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensorFullOvf.cs new file mode 100644 index 000000000000..94f357b0cd71 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsSensorFullOvf.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Contains all OVF (virtual machine) full versions for the sensor + /// + public partial class PackageDownloadsSensorFullOvf + { + /// + /// Initializes a new instance of the PackageDownloadsSensorFullOvf + /// class. + /// + public PackageDownloadsSensorFullOvf() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PackageDownloadsSensorFullOvf + /// class. + /// + /// Enterprise package type + /// Medium package type + /// Line package type + public PackageDownloadsSensorFullOvf(IList enterprise = default(IList), IList medium = default(IList), IList line = default(IList)) + { + Enterprise = enterprise; + Medium = medium; + Line = line; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets enterprise package type + /// + [JsonProperty(PropertyName = "enterprise")] + public IList Enterprise { get; private set; } + + /// + /// Gets medium package type + /// + [JsonProperty(PropertyName = "medium")] + public IList Medium { get; private set; } + + /// + /// Gets line package type + /// + [JsonProperty(PropertyName = "line")] + public IList Line { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsThreatIntelligence.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsThreatIntelligence.cs new file mode 100644 index 000000000000..38058ad743fc --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PackageDownloadsThreatIntelligence.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// All downloads for threat intelligence + /// + public partial class PackageDownloadsThreatIntelligence + { + /// + /// Initializes a new instance of the + /// PackageDownloadsThreatIntelligence class. + /// + public PackageDownloadsThreatIntelligence() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PackageDownloadsThreatIntelligence class. + /// + /// Download link + public PackageDownloadsThreatIntelligence(string link = default(string)) + { + Link = link; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets download link + /// + [JsonProperty(PropertyName = "link")] + public string Link { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PathRecommendation.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PathRecommendation.cs index 36774200ed2c..d55253f6d73d 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PathRecommendation.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PathRecommendation.cs @@ -31,13 +31,14 @@ public PathRecommendation() /// /// Initializes a new instance of the PathRecommendation class. /// - /// The full path to whitelist + /// The full path of the file, or an identifier of + /// the application /// Possible values include: 'Recommended', 'Add', /// 'Remove' /// Possible values include: 'File', 'FileHash', /// 'PublisherSignature', 'ProductSignature', 'BinarySignature', /// 'VersionAndAboveSignature' - /// Whether the path is commonly run on the + /// Whether the application is commonly run on the /// machine /// Possible values include: 'Exe', 'Dll', /// 'Msi', 'Script', 'Executable', 'Unknown' @@ -64,7 +65,8 @@ public PathRecommendation() partial void CustomInit(); /// - /// Gets or sets the full path to whitelist + /// Gets or sets the full path of the file, or an identifier of the + /// application /// [JsonProperty(PropertyName = "path")] public string Path { get; set; } @@ -90,7 +92,7 @@ public PathRecommendation() public PublisherInfo PublisherInfo { get; set; } /// - /// Gets or sets whether the path is commonly run on the machine + /// Gets or sets whether the application is commonly run on the machine /// [JsonProperty(PropertyName = "common")] public bool? Common { get; set; } diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PermissionProperty.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PermissionProperty.cs new file mode 100644 index 000000000000..0e08aa9fcd72 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PermissionProperty.cs @@ -0,0 +1,40 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for PermissionProperty. + /// + public static class PermissionProperty + { + /// + /// This permission provides read only access to AWS Security Hub + /// resources. + /// + public const string AWSAWSSecurityHubReadOnlyAccess = "AWS::AWSSecurityHubReadOnlyAccess"; + /// + /// This permission grants access to read security configuration + /// metadata. + /// + public const string AWSSecurityAudit = "AWS::SecurityAudit"; + /// + /// The permission provides for EC2 Automation service to execute + /// activities defined within Automation documents. + /// + public const string AWSAmazonSSMAutomationRole = "AWS::AmazonSSMAutomationRole"; + /// + /// This permission provides read only access to GCP Security Command + /// Center. + /// + public const string GCPSecurityCenterAdminViewer = "GCP::Security Center Admin Viewer"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProcessNotAllowed.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProcessNotAllowed.cs index 66e7dc1f46f9..a69d3dc5f932 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProcessNotAllowed.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProcessNotAllowed.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -19,7 +18,6 @@ namespace Microsoft.Azure.Management.Security.Models /// Execution of a process that isn't allowed. Allow list consists of /// process names to allow. /// - [Newtonsoft.Json.JsonObject("ProcessNotAllowed")] public partial class ProcessNotAllowed : AllowlistCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProgrammingState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProgrammingState.cs new file mode 100644 index 000000000000..c157c76a1e66 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProgrammingState.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.Security.Models +{ + + /// + /// Defines values for ProgrammingState. + /// + public static class ProgrammingState + { + public const string ProgrammingDevice = "ProgrammingDevice"; + public const string NotProgrammingDevice = "NotProgrammingDevice"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Protocol1.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Protocol1.cs new file mode 100644 index 000000000000..2bd92aa67191 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Protocol1.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Protocol data + /// + public partial class Protocol1 + { + /// + /// Initializes a new instance of the Protocol1 class. + /// + public Protocol1() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Protocol1 class. + /// + /// Protocol name + /// list of protocol identifiers. + public Protocol1(string name = default(string), string identifiers = default(string)) + { + Name = name; + Identifiers = identifiers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets protocol name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets list of protocol identifiers. + /// + [JsonProperty(PropertyName = "identifiers")] + public string Identifiers { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProvisioningState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..3402e79694b0 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for ProvisioningState. + /// + public static class ProvisioningState + { + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Updating = "Updating"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProxyServerProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProxyServerProperties.cs new file mode 100644 index 000000000000..2f0253d64a38 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ProxyServerProperties.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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// For a non-Azure machine that is not connected directly to the internet, + /// specify a proxy server that the non-Azure machine can use. + /// + public partial class ProxyServerProperties + { + /// + /// Initializes a new instance of the ProxyServerProperties class. + /// + public ProxyServerProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyServerProperties class. + /// + /// Proxy server IP + /// Proxy server port + public ProxyServerProperties(string ip = default(string), string port = default(string)) + { + Ip = ip; + Port = port; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets proxy server IP + /// + [JsonProperty(PropertyName = "ip")] + public string Ip { get; set; } + + /// + /// Gets or sets proxy server port + /// + [JsonProperty(PropertyName = "port")] + public string Port { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PurdueLevel.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PurdueLevel.cs new file mode 100644 index 000000000000..95e824791b1e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/PurdueLevel.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for PurdueLevel. + /// + public static class PurdueLevel + { + public const string ProcessControl = "ProcessControl"; + public const string Supervisory = "Supervisory"; + public const string Enterprise = "Enterprise"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueryCheck.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueryCheck.cs new file mode 100644 index 000000000000..3150c3f2832b --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueryCheck.cs @@ -0,0 +1,69 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The rule query details. + /// + public partial class QueryCheck + { + /// + /// Initializes a new instance of the QueryCheck class. + /// + public QueryCheck() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryCheck class. + /// + /// The rule query. + /// Expected result. + /// Column names of expected result. + public QueryCheck(string query = default(string), IList> expectedResult = default(IList>), IList columnNames = default(IList)) + { + Query = query; + ExpectedResult = expectedResult; + ColumnNames = columnNames; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the rule query. + /// + [JsonProperty(PropertyName = "query")] + public string Query { get; set; } + + /// + /// Gets or sets expected result. + /// + [JsonProperty(PropertyName = "expectedResult")] + public IList> ExpectedResult { get; set; } + + /// + /// Gets or sets column names of expected result. + /// + [JsonProperty(PropertyName = "columnNames")] + public IList ColumnNames { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueuePurgesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueuePurgesNotInAllowedRange.cs index e7a506d93b60..6845776d0aed 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueuePurgesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/QueuePurgesNotInAllowedRange.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of device queue purges is not in allowed range. /// - [Newtonsoft.Json.JsonObject("QueuePurgesNotInAllowedRange")] public partial class QueuePurgesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RecommendationSeverity.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RecommendationSeverity.cs new file mode 100644 index 000000000000..7752a3f4f198 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RecommendationSeverity.cs @@ -0,0 +1,27 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for RecommendationSeverity. + /// + public static class RecommendationSeverity + { + public const string Unknown = "Unknown"; + public const string NotApplicable = "NotApplicable"; + public const string Healthy = "Healthy"; + public const string OffByPolicy = "OffByPolicy"; + public const string Low = "Low"; + public const string Medium = "Medium"; + public const string High = "High"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RelationToIpStatus.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RelationToIpStatus.cs new file mode 100644 index 000000000000..5e97e16405b9 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RelationToIpStatus.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.Security.Models +{ + + /// + /// Defines values for RelationToIpStatus. + /// + public static class RelationToIpStatus + { + public const string Guess = "Guess"; + public const string Certain = "Certain"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Remediation.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Remediation.cs new file mode 100644 index 000000000000..16eb64f95179 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Remediation.cs @@ -0,0 +1,78 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Remediation details. + /// + public partial class Remediation + { + /// + /// Initializes a new instance of the Remediation class. + /// + public Remediation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Remediation class. + /// + /// Remediation description. + /// Remediation script. + /// Is remediation automated. + /// Optional link to remediate in Azure + /// Portal. + public Remediation(string description = default(string), IList scripts = default(IList), bool? automated = default(bool?), string portalLink = default(string)) + { + Description = description; + Scripts = scripts; + Automated = automated; + PortalLink = portalLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets remediation description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets remediation script. + /// + [JsonProperty(PropertyName = "scripts")] + public IList Scripts { get; set; } + + /// + /// Gets or sets is remediation automated. + /// + [JsonProperty(PropertyName = "automated")] + public bool? Automated { get; set; } + + /// + /// Gets or sets optional link to remediate in Azure Portal. + /// + [JsonProperty(PropertyName = "portalLink")] + public string PortalLink { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceDetails.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceDetails.cs index 6ab1d4f7544f..14c1aa733667 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceDetails.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceDetails.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Details of the resource that was assessed /// - [Newtonsoft.Json.JsonObject("ResourceDetails")] public partial class ResourceDetails { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceIdentifier.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceIdentifier.cs new file mode 100644 index 000000000000..bc31b41d1edd --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ResourceIdentifier.cs @@ -0,0 +1,37 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using System.Linq; + + /// + /// A resource identifier for an alert which can be used to direct the + /// alert to the right product exposure group (tenant, workspace, + /// subscription etc.). + /// + public partial class ResourceIdentifier + { + /// + /// Initializes a new instance of the ResourceIdentifier class. + /// + public ResourceIdentifier() + { + CustomInit(); + } + + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResults.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResults.cs new file mode 100644 index 000000000000..6e8fe66927d2 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResults.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Rule results. + /// + public partial class RuleResults : Resource + { + /// + /// Initializes a new instance of the RuleResults class. + /// + public RuleResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleResults class. + /// + /// Resource Id + /// Resource name + /// Resource type + public RuleResults(string id = default(string), string name = default(string), string type = default(string), RuleResultsProperties properties = default(RuleResultsProperties)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public RuleResultsProperties Properties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResultsInput.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResultsInput.cs new file mode 100644 index 000000000000..48175a551b15 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResultsInput.cs @@ -0,0 +1,64 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Rule results input. + /// + public partial class RuleResultsInput + { + /// + /// Initializes a new instance of the RuleResultsInput class. + /// + public RuleResultsInput() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleResultsInput class. + /// + /// Take results from latest scan. + /// Expected results to be inserted into the + /// baseline. + /// Leave this field empty it LatestScan == true. + public RuleResultsInput(bool? latestScan = default(bool?), IList> results = default(IList>)) + { + LatestScan = latestScan; + Results = results; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets take results from latest scan. + /// + [JsonProperty(PropertyName = "latestScan")] + public bool? LatestScan { get; set; } + + /// + /// Gets or sets expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + [JsonProperty(PropertyName = "results")] + public IList> Results { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResultsProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResultsProperties.cs new file mode 100644 index 000000000000..b2ac5f11bd07 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleResultsProperties.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Rule results properties. + /// + public partial class RuleResultsProperties + { + /// + /// Initializes a new instance of the RuleResultsProperties class. + /// + public RuleResultsProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleResultsProperties class. + /// + /// Expected results in the baseline. + public RuleResultsProperties(IList> results = default(IList>)) + { + Results = results; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets expected results in the baseline. + /// + [JsonProperty(PropertyName = "results")] + public IList> Results { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleSeverity.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleSeverity.cs new file mode 100644 index 000000000000..b8a0d9d07aa2 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleSeverity.cs @@ -0,0 +1,40 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for RuleSeverity. + /// + public static class RuleSeverity + { + /// + /// High + /// + public const string High = "High"; + /// + /// Medium + /// + public const string Medium = "Medium"; + /// + /// Low + /// + public const string Low = "Low"; + /// + /// Informational + /// + public const string Informational = "Informational"; + /// + /// Obsolete + /// + public const string Obsolete = "Obsolete"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleState.cs new file mode 100644 index 000000000000..0387421fabb7 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleState.cs @@ -0,0 +1,66 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for RuleState. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RuleState + { + [EnumMember(Value = "Enabled")] + Enabled, + [EnumMember(Value = "Disabled")] + Disabled, + [EnumMember(Value = "Expired")] + Expired + } + internal static class RuleStateEnumExtension + { + internal static string ToSerializedValue(this RuleState? value) + { + return value == null ? null : ((RuleState)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this RuleState value) + { + switch( value ) + { + case RuleState.Enabled: + return "Enabled"; + case RuleState.Disabled: + return "Disabled"; + case RuleState.Expired: + return "Expired"; + } + return null; + } + + internal static RuleState? ParseRuleState(this string value) + { + switch( value ) + { + case "Enabled": + return RuleState.Enabled; + case "Disabled": + return RuleState.Disabled; + case "Expired": + return RuleState.Expired; + } + return null; + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleStatus.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleStatus.cs new file mode 100644 index 000000000000..cf84cb6f5d92 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleStatus.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for RuleStatus. + /// + public static class RuleStatus + { + /// + /// NonFinding + /// + public const string NonFinding = "NonFinding"; + /// + /// Finding + /// + public const string Finding = "Finding"; + /// + /// InternalError + /// + public const string InternalError = "InternalError"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleType.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleType.cs new file mode 100644 index 000000000000..994750901819 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RuleType.cs @@ -0,0 +1,36 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for RuleType. + /// + public static class RuleType + { + /// + /// Binary + /// + public const string Binary = "Binary"; + /// + /// BaselineExpected + /// + public const string BaselineExpected = "BaselineExpected"; + /// + /// PositiveList + /// + public const string PositiveList = "PositiveList"; + /// + /// NegativeList + /// + public const string NegativeList = "NegativeList"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RulesResults.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RulesResults.cs new file mode 100644 index 000000000000..6b7f1bacf56e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RulesResults.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of rules results. + /// + public partial class RulesResults + { + /// + /// Initializes a new instance of the RulesResults class. + /// + public RulesResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RulesResults class. + /// + /// List of rule results. + public RulesResults(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of rule results. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RulesResultsInput.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RulesResultsInput.cs new file mode 100644 index 000000000000..0a4174ce060e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/RulesResultsInput.cs @@ -0,0 +1,64 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Rules results input. + /// + public partial class RulesResultsInput + { + /// + /// Initializes a new instance of the RulesResultsInput class. + /// + public RulesResultsInput() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RulesResultsInput class. + /// + /// Take results from latest scan. + /// Expected results to be inserted into the + /// baseline. + /// Leave this field empty it LatestScan == true. + public RulesResultsInput(bool? latestScan = default(bool?), IDictionary>> results = default(IDictionary>>)) + { + LatestScan = latestScan; + Results = results; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets take results from latest scan. + /// + [JsonProperty(PropertyName = "latestScan")] + public bool? LatestScan { get; set; } + + /// + /// Gets or sets expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + [JsonProperty(PropertyName = "results")] + public IDictionary>> Results { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Scan.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Scan.cs new file mode 100644 index 000000000000..5df07a4230bf --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Scan.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A vulnerability assessment scan record. + /// + public partial class Scan : Resource + { + /// + /// Initializes a new instance of the Scan class. + /// + public Scan() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Scan class. + /// + /// Resource Id + /// Resource name + /// Resource type + public Scan(string id = default(string), string name = default(string), string type = default(string), ScanProperties properties = default(ScanProperties)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public ScanProperties Properties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanProperties.cs new file mode 100644 index 000000000000..0ed039291522 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanProperties.cs @@ -0,0 +1,167 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A vulnerability assessment scan record properties. + /// + public partial class ScanProperties + { + /// + /// Initializes a new instance of the ScanProperties class. + /// + public ScanProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScanProperties class. + /// + /// Possible values include: 'OnDemand', + /// 'Recurring' + /// Possible values include: 'Failed', + /// 'FailedToRun', 'InProgress', 'Passed' + /// The server name. + /// The database name. + /// The SQL version. + /// The scan start time (UTC). + /// Scan results are valid until end time + /// (UTC). + /// The number of failed + /// rules with high severity. + /// The number of failed + /// rules with medium severity. + /// The number of failed + /// rules with low severity. + /// The number of total passed + /// rules. + /// The number of total failed + /// rules. + /// The number of total rules + /// assessed. + /// Baseline created for this database, + /// and has one or more rules. + public ScanProperties(string triggerType = default(string), string state = default(string), string server = default(string), string database = default(string), string sqlVersion = default(string), System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), int? highSeverityFailedRulesCount = default(int?), int? mediumSeverityFailedRulesCount = default(int?), int? lowSeverityFailedRulesCount = default(int?), int? totalPassedRulesCount = default(int?), int? totalFailedRulesCount = default(int?), int? totalRulesCount = default(int?), bool? isBaselineApplied = default(bool?)) + { + TriggerType = triggerType; + State = state; + Server = server; + Database = database; + SqlVersion = sqlVersion; + StartTime = startTime; + EndTime = endTime; + HighSeverityFailedRulesCount = highSeverityFailedRulesCount; + MediumSeverityFailedRulesCount = mediumSeverityFailedRulesCount; + LowSeverityFailedRulesCount = lowSeverityFailedRulesCount; + TotalPassedRulesCount = totalPassedRulesCount; + TotalFailedRulesCount = totalFailedRulesCount; + TotalRulesCount = totalRulesCount; + IsBaselineApplied = isBaselineApplied; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'OnDemand', 'Recurring' + /// + [JsonProperty(PropertyName = "triggerType")] + public string TriggerType { get; set; } + + /// + /// Gets or sets possible values include: 'Failed', 'FailedToRun', + /// 'InProgress', 'Passed' + /// + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// Gets or sets the server name. + /// + [JsonProperty(PropertyName = "server")] + public string Server { get; set; } + + /// + /// Gets or sets the database name. + /// + [JsonProperty(PropertyName = "database")] + public string Database { get; set; } + + /// + /// Gets or sets the SQL version. + /// + [JsonProperty(PropertyName = "sqlVersion")] + public string SqlVersion { get; set; } + + /// + /// Gets or sets the scan start time (UTC). + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; set; } + + /// + /// Gets or sets scan results are valid until end time (UTC). + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; set; } + + /// + /// Gets or sets the number of failed rules with high severity. + /// + [JsonProperty(PropertyName = "highSeverityFailedRulesCount")] + public int? HighSeverityFailedRulesCount { get; set; } + + /// + /// Gets or sets the number of failed rules with medium severity. + /// + [JsonProperty(PropertyName = "mediumSeverityFailedRulesCount")] + public int? MediumSeverityFailedRulesCount { get; set; } + + /// + /// Gets or sets the number of failed rules with low severity. + /// + [JsonProperty(PropertyName = "lowSeverityFailedRulesCount")] + public int? LowSeverityFailedRulesCount { get; set; } + + /// + /// Gets or sets the number of total passed rules. + /// + [JsonProperty(PropertyName = "totalPassedRulesCount")] + public int? TotalPassedRulesCount { get; set; } + + /// + /// Gets or sets the number of total failed rules. + /// + [JsonProperty(PropertyName = "totalFailedRulesCount")] + public int? TotalFailedRulesCount { get; set; } + + /// + /// Gets or sets the number of total rules assessed. + /// + [JsonProperty(PropertyName = "totalRulesCount")] + public int? TotalRulesCount { get; set; } + + /// + /// Gets or sets baseline created for this database, and has one or + /// more rules. + /// + [JsonProperty(PropertyName = "isBaselineApplied")] + public bool? IsBaselineApplied { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResult.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResult.cs new file mode 100644 index 000000000000..1cda1f43e431 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResult.cs @@ -0,0 +1,53 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A vulnerability assessment scan result for a single rule. + /// + public partial class ScanResult : Resource + { + /// + /// Initializes a new instance of the ScanResult class. + /// + public ScanResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScanResult class. + /// + /// Resource Id + /// Resource name + /// Resource type + public ScanResult(string id = default(string), string name = default(string), string type = default(string), ScanResultProperties properties = default(ScanResultProperties)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public ScanResultProperties Properties { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResultProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResultProperties.cs new file mode 100644 index 000000000000..8693056eed0e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResultProperties.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A vulnerability assessment scan result properties for a single rule. + /// + public partial class ScanResultProperties + { + /// + /// Initializes a new instance of the ScanResultProperties class. + /// + public ScanResultProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScanResultProperties class. + /// + /// The rule Id. + /// Possible values include: 'NonFinding', + /// 'Finding', 'InternalError' + /// Indicated whether the results specified + /// here are trimmed. + /// The results of the query that was + /// run. + public ScanResultProperties(string ruleId = default(string), string status = default(string), bool? isTrimmed = default(bool?), IList> queryResults = default(IList>), Remediation remediation = default(Remediation), BaselineAdjustedResult baselineAdjustedResult = default(BaselineAdjustedResult), VaRule ruleMetadata = default(VaRule)) + { + RuleId = ruleId; + Status = status; + IsTrimmed = isTrimmed; + QueryResults = queryResults; + Remediation = remediation; + BaselineAdjustedResult = baselineAdjustedResult; + RuleMetadata = ruleMetadata; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the rule Id. + /// + [JsonProperty(PropertyName = "ruleId")] + public string RuleId { get; set; } + + /// + /// Gets or sets possible values include: 'NonFinding', 'Finding', + /// 'InternalError' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets indicated whether the results specified here are + /// trimmed. + /// + [JsonProperty(PropertyName = "isTrimmed")] + public bool? IsTrimmed { get; set; } + + /// + /// Gets or sets the results of the query that was run. + /// + [JsonProperty(PropertyName = "queryResults")] + public IList> QueryResults { get; set; } + + /// + /// + [JsonProperty(PropertyName = "remediation")] + public Remediation Remediation { get; set; } + + /// + /// + [JsonProperty(PropertyName = "baselineAdjustedResult")] + public BaselineAdjustedResult BaselineAdjustedResult { get; set; } + + /// + /// + [JsonProperty(PropertyName = "ruleMetadata")] + public VaRule RuleMetadata { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResults.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResults.cs new file mode 100644 index 000000000000..82b3c05f7285 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanResults.cs @@ -0,0 +1,54 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of vulnerability assessment scan results. + /// + public partial class ScanResults + { + /// + /// Initializes a new instance of the ScanResults class. + /// + public ScanResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScanResults class. + /// + /// List of vulnerability assessment scan + /// results. + public ScanResults(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of vulnerability assessment scan results. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanState.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanState.cs new file mode 100644 index 000000000000..ccda47c95700 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanState.cs @@ -0,0 +1,36 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for ScanState. + /// + public static class ScanState + { + /// + /// Failed + /// + public const string Failed = "Failed"; + /// + /// FailedToRun + /// + public const string FailedToRun = "FailedToRun"; + /// + /// InProgress + /// + public const string InProgress = "InProgress"; + /// + /// Passed + /// + public const string Passed = "Passed"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanTriggerType.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanTriggerType.cs new file mode 100644 index 000000000000..5ffd2c8c6dfe --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanTriggerType.cs @@ -0,0 +1,28 @@ +// +// 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.Security.Models +{ + + /// + /// Defines values for ScanTriggerType. + /// + public static class ScanTriggerType + { + /// + /// OnDemand + /// + public const string OnDemand = "OnDemand"; + /// + /// Recurring + /// + public const string Recurring = "Recurring"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanningFunctionality.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanningFunctionality.cs new file mode 100644 index 000000000000..1c5b576b6f8d --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScanningFunctionality.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.Security.Models +{ + + /// + /// Defines values for ScanningFunctionality. + /// + public static class ScanningFunctionality + { + public const string ScannerDevice = "ScannerDevice"; + public const string NotScannerDevice = "NotScannerDevice"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Scans.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Scans.cs new file mode 100644 index 000000000000..4ccc0445a988 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Scans.cs @@ -0,0 +1,54 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of vulnerability assessment scan records. + /// + public partial class Scans + { + /// + /// Initializes a new instance of the Scans class. + /// + public Scans() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Scans class. + /// + /// List of vulnerability assessment scan + /// records. + public Scans(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of vulnerability assessment scan records. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScopeElement.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScopeElement.cs new file mode 100644 index 000000000000..c7c0bd533565 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ScopeElement.cs @@ -0,0 +1,63 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A more specific scope used to identify the alerts to suppress. + /// + public partial class ScopeElement + { + /// + /// Initializes a new instance of the ScopeElement class. + /// + public ScopeElement() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScopeElement class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// The alert entity type to suppress by. + public ScopeElement(IDictionary additionalProperties = default(IDictionary), string field = default(string)) + { + AdditionalProperties = additionalProperties; + Field = field; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Gets or sets the alert entity type to suppress by. + /// + [JsonProperty(PropertyName = "field")] + public string Field { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDefinitionItem.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDefinitionItem.cs new file mode 100644 index 000000000000..b00aa0b76545 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDefinitionItem.cs @@ -0,0 +1,123 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Information about the security control. + /// + [Rest.Serialization.JsonTransformation] + public partial class SecureScoreControlDefinitionItem : Resource + { + /// + /// Initializes a new instance of the SecureScoreControlDefinitionItem + /// class. + /// + public SecureScoreControlDefinitionItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecureScoreControlDefinitionItem + /// class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// User friendly display name of the + /// control + /// User friendly description of the + /// control + /// Maximum control score (0..10) + /// Source object from which the control was + /// created + /// Array of assessments metadata + /// IDs that are included in this security control + public SecureScoreControlDefinitionItem(string id = default(string), string name = default(string), string type = default(string), string displayName = default(string), string description = default(string), int? maxScore = default(int?), SecureScoreControlDefinitionSource source = default(SecureScoreControlDefinitionSource), IList assessmentDefinitions = default(IList)) + : base(id, name, type) + { + DisplayName = displayName; + Description = description; + MaxScore = maxScore; + Source = source; + AssessmentDefinitions = assessmentDefinitions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets user friendly display name of the control + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets user friendly description of the control + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets maximum control score (0..10) + /// + [JsonProperty(PropertyName = "properties.maxScore")] + public int? MaxScore { get; private set; } + + /// + /// Gets source object from which the control was created + /// + [JsonProperty(PropertyName = "properties.source")] + public SecureScoreControlDefinitionSource Source { get; private set; } + + /// + /// Gets array of assessments metadata IDs that are included in this + /// security control + /// + [JsonProperty(PropertyName = "properties.assessmentDefinitions")] + public IList AssessmentDefinitions { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Description != null) + { + if (Description.Length > 256) + { + throw new ValidationException(ValidationRules.MaxLength, "Description", 256); + } + } + if (MaxScore > 10) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "MaxScore", 10); + } + if (MaxScore < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "MaxScore", 0); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDefinitionSource.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDefinitionSource.cs new file mode 100644 index 000000000000..b7b1aed385e0 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDefinitionSource.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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The type of the security control (For example, BuiltIn) + /// + public partial class SecureScoreControlDefinitionSource + { + /// + /// Initializes a new instance of the + /// SecureScoreControlDefinitionSource class. + /// + public SecureScoreControlDefinitionSource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SecureScoreControlDefinitionSource class. + /// + /// The type of security control (for example, + /// BuiltIn). Possible values include: 'BuiltIn', 'Custom' + public SecureScoreControlDefinitionSource(string sourceType = default(string)) + { + SourceType = sourceType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of security control (for example, BuiltIn). + /// Possible values include: 'BuiltIn', 'Custom' + /// + [JsonProperty(PropertyName = "sourceType")] + public string SourceType { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDetails.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDetails.cs new file mode 100644 index 000000000000..731ad402ecdc --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlDetails.cs @@ -0,0 +1,164 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of the security control, its score, and the health status of + /// the relevant resources. + /// + [Rest.Serialization.JsonTransformation] + public partial class SecureScoreControlDetails : Resource + { + /// + /// Initializes a new instance of the SecureScoreControlDetails class. + /// + public SecureScoreControlDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecureScoreControlDetails class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// User friendly display name of the + /// control + /// Maximum score available + /// Current score + /// Ratio of the current score divided by the + /// maximum. Rounded to 4 digits after the decimal point + /// Number of healthy resources in + /// the control + /// Number of unhealthy resources + /// in the control + /// Number of not applicable + /// resources in the control + /// The relative weight for this specific control + /// in each of your subscriptions. Used when calculating an aggregated + /// score for this control across all of your subscriptions. + public SecureScoreControlDetails(string id = default(string), string name = default(string), string type = default(string), string displayName = default(string), int? max = default(int?), double? current = default(double?), double? percentage = default(double?), int? healthyResourceCount = default(int?), int? unhealthyResourceCount = default(int?), int? notApplicableResourceCount = default(int?), long? weight = default(long?), SecureScoreControlDefinitionItem definition = default(SecureScoreControlDefinitionItem)) + : base(id, name, type) + { + DisplayName = displayName; + Max = max; + Current = current; + Percentage = percentage; + HealthyResourceCount = healthyResourceCount; + UnhealthyResourceCount = unhealthyResourceCount; + NotApplicableResourceCount = notApplicableResourceCount; + Weight = weight; + Definition = definition; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets user friendly display name of the control + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets maximum score available + /// + [JsonProperty(PropertyName = "properties.score.max")] + public int? Max { get; private set; } + + /// + /// Gets current score + /// + [JsonProperty(PropertyName = "properties.score.current")] + public double? Current { get; private set; } + + /// + /// Gets ratio of the current score divided by the maximum. Rounded to + /// 4 digits after the decimal point + /// + [JsonProperty(PropertyName = "properties.score.percentage")] + public double? Percentage { get; private set; } + + /// + /// Gets number of healthy resources in the control + /// + [JsonProperty(PropertyName = "properties.healthyResourceCount")] + public int? HealthyResourceCount { get; private set; } + + /// + /// Gets number of unhealthy resources in the control + /// + [JsonProperty(PropertyName = "properties.unhealthyResourceCount")] + public int? UnhealthyResourceCount { get; private set; } + + /// + /// Gets number of not applicable resources in the control + /// + [JsonProperty(PropertyName = "properties.notApplicableResourceCount")] + public int? NotApplicableResourceCount { get; private set; } + + /// + /// Gets the relative weight for this specific control in each of your + /// subscriptions. Used when calculating an aggregated score for this + /// control across all of your subscriptions. + /// + [JsonProperty(PropertyName = "properties.weight")] + public long? Weight { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties.definition")] + public SecureScoreControlDefinitionItem Definition { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Max < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Max", 0); + } + if (Current < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Current", 0); + } + if (Percentage > 1) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Percentage", 1); + } + if (Percentage < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Percentage", 0); + } + if (Weight < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Weight", 0); + } + if (Definition != null) + { + Definition.Validate(); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlScore.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlScore.cs new file mode 100644 index 000000000000..0c5bcb1169af --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreControlScore.cs @@ -0,0 +1,107 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Calculation result data + /// + public partial class SecureScoreControlScore + { + /// + /// Initializes a new instance of the SecureScoreControlScore class. + /// + public SecureScoreControlScore() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecureScoreControlScore class. + /// + /// Maximum control score (0..10) + /// Actual score for the control = (achieved + /// points / total points) * max score. if total points is zeroed, the + /// return number is 0.00 + /// Ratio of the current score divided by the + /// maximum. Rounded to 4 digits after the decimal point + public SecureScoreControlScore(int? max = default(int?), double? current = default(double?), double? percentage = default(double?)) + { + Max = max; + Current = current; + Percentage = percentage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets maximum control score (0..10) + /// + [JsonProperty(PropertyName = "max")] + public int? Max { get; private set; } + + /// + /// Gets actual score for the control = (achieved points / total + /// points) * max score. if total points is zeroed, the return number + /// is 0.00 + /// + [JsonProperty(PropertyName = "current")] + public double? Current { get; private set; } + + /// + /// Gets ratio of the current score divided by the maximum. Rounded to + /// 4 digits after the decimal point + /// + [JsonProperty(PropertyName = "percentage")] + public double? Percentage { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Max > 10) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Max", 10); + } + if (Max < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Max", 0); + } + if (Current > 10) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Current", 10); + } + if (Current < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Current", 0); + } + if (Percentage > 1) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Percentage", 1); + } + if (Percentage < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Percentage", 0); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreItem.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreItem.cs new file mode 100644 index 000000000000..eef77dd1344f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecureScoreItem.cs @@ -0,0 +1,124 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Secure score item data model + /// + [Rest.Serialization.JsonTransformation] + public partial class SecureScoreItem : Resource + { + /// + /// Initializes a new instance of the SecureScoreItem class. + /// + public SecureScoreItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecureScoreItem class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// The initiative’s name + /// Maximum score available + /// Current score + /// Ratio of the current score divided by the + /// maximum. Rounded to 4 digits after the decimal point + /// The relative weight for each subscription. + /// Used when calculating an aggregated secure score for multiple + /// subscriptions. + public SecureScoreItem(string id = default(string), string name = default(string), string type = default(string), string displayName = default(string), int? max = default(int?), double? current = default(double?), double? percentage = default(double?), long? weight = default(long?)) + : base(id, name, type) + { + DisplayName = displayName; + Max = max; + Current = current; + Percentage = percentage; + Weight = weight; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the initiative’s name + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets maximum score available + /// + [JsonProperty(PropertyName = "properties.score.max")] + public int? Max { get; private set; } + + /// + /// Gets current score + /// + [JsonProperty(PropertyName = "properties.score.current")] + public double? Current { get; private set; } + + /// + /// Gets ratio of the current score divided by the maximum. Rounded to + /// 4 digits after the decimal point + /// + [JsonProperty(PropertyName = "properties.score.percentage")] + public double? Percentage { get; private set; } + + /// + /// Gets the relative weight for each subscription. Used when + /// calculating an aggregated secure score for multiple subscriptions. + /// + [JsonProperty(PropertyName = "properties.weight")] + public long? Weight { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Max < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Max", 0); + } + if (Current < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Current", 0); + } + if (Percentage > 1) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Percentage", 1); + } + if (Percentage < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Percentage", 0); + } + if (Weight < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Weight", 0); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolution.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolution.cs new file mode 100644 index 000000000000..3b11e243b80e --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolution.cs @@ -0,0 +1,140 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + [Rest.Serialization.JsonTransformation] + public partial class SecuritySolution + { + /// + /// Initializes a new instance of the SecuritySolution class. + /// + public SecuritySolution() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecuritySolution class. + /// + /// The security family of the security + /// solution. Possible values include: 'Waf', 'Ngfw', 'SaasWaf', + /// 'Va' + /// The security family provisioning + /// State. Possible values include: 'Succeeded', 'Failed', + /// 'Updating' + /// The security solutions' template + /// The security solutions' + /// status + /// Resource Id + /// Resource name + /// Resource type + /// Location where the resource is + /// stored + public SecuritySolution(string securityFamily, string provisioningState, string template, string protectionStatus, string id = default(string), string name = default(string), string type = default(string), string location = default(string)) + { + Id = id; + Name = name; + Type = type; + Location = location; + SecurityFamily = securityFamily; + ProvisioningState = provisioningState; + Template = template; + ProtectionStatus = protectionStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets location where the resource is stored + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets or sets the security family of the security solution. Possible + /// values include: 'Waf', 'Ngfw', 'SaasWaf', 'Va' + /// + [JsonProperty(PropertyName = "properties.securityFamily")] + public string SecurityFamily { get; set; } + + /// + /// Gets or sets the security family provisioning State. Possible + /// values include: 'Succeeded', 'Failed', 'Updating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the security solutions' template + /// + [JsonProperty(PropertyName = "properties.template")] + public string Template { get; set; } + + /// + /// Gets or sets the security solutions' status + /// + [JsonProperty(PropertyName = "properties.protectionStatus")] + public string ProtectionStatus { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SecurityFamily == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SecurityFamily"); + } + if (ProvisioningState == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ProvisioningState"); + } + if (Template == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Template"); + } + if (ProtectionStatus == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ProtectionStatus"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolutionsReferenceData.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolutionsReferenceData.cs new file mode 100644 index 000000000000..fb9f193a9b77 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolutionsReferenceData.cs @@ -0,0 +1,178 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + [Rest.Serialization.JsonTransformation] + public partial class SecuritySolutionsReferenceData + { + /// + /// Initializes a new instance of the SecuritySolutionsReferenceData + /// class. + /// + public SecuritySolutionsReferenceData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecuritySolutionsReferenceData + /// class. + /// + /// The security family of the security + /// solution. Possible values include: 'Waf', 'Ngfw', 'SaasWaf', + /// 'Va' + /// The security solutions' vendor + /// name + /// The security solutions' package info + /// url + /// The security solutions' product + /// name + /// The security solutions' publisher + /// The security solutions' + /// publisher display name + /// The security solutions' template + /// Resource Id + /// Resource name + /// Resource type + /// Location where the resource is + /// stored + public SecuritySolutionsReferenceData(string securityFamily, string alertVendorName, string packageInfoUrl, string productName, string publisher, string publisherDisplayName, string template, string id = default(string), string name = default(string), string type = default(string), string location = default(string)) + { + Id = id; + Name = name; + Type = type; + Location = location; + SecurityFamily = securityFamily; + AlertVendorName = alertVendorName; + PackageInfoUrl = packageInfoUrl; + ProductName = productName; + Publisher = publisher; + PublisherDisplayName = publisherDisplayName; + Template = template; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets location where the resource is stored + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets or sets the security family of the security solution. Possible + /// values include: 'Waf', 'Ngfw', 'SaasWaf', 'Va' + /// + [JsonProperty(PropertyName = "properties.securityFamily")] + public string SecurityFamily { get; set; } + + /// + /// Gets or sets the security solutions' vendor name + /// + [JsonProperty(PropertyName = "properties.alertVendorName")] + public string AlertVendorName { get; set; } + + /// + /// Gets or sets the security solutions' package info url + /// + [JsonProperty(PropertyName = "properties.packageInfoUrl")] + public string PackageInfoUrl { get; set; } + + /// + /// Gets or sets the security solutions' product name + /// + [JsonProperty(PropertyName = "properties.productName")] + public string ProductName { get; set; } + + /// + /// Gets or sets the security solutions' publisher + /// + [JsonProperty(PropertyName = "properties.publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets the security solutions' publisher display name + /// + [JsonProperty(PropertyName = "properties.publisherDisplayName")] + public string PublisherDisplayName { get; set; } + + /// + /// Gets or sets the security solutions' template + /// + [JsonProperty(PropertyName = "properties.template")] + public string Template { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SecurityFamily == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SecurityFamily"); + } + if (AlertVendorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AlertVendorName"); + } + if (PackageInfoUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PackageInfoUrl"); + } + if (ProductName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ProductName"); + } + if (Publisher == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Publisher"); + } + if (PublisherDisplayName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PublisherDisplayName"); + } + if (Template == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Template"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolutionsReferenceDataList.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolutionsReferenceDataList.cs new file mode 100644 index 000000000000..9f49c1c98659 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SecuritySolutionsReferenceDataList.cs @@ -0,0 +1,50 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class SecuritySolutionsReferenceDataList + { + /// + /// Initializes a new instance of the + /// SecuritySolutionsReferenceDataList class. + /// + public SecuritySolutionsReferenceDataList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SecuritySolutionsReferenceDataList class. + /// + public SecuritySolutionsReferenceDataList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Sensor.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Sensor.cs new file mode 100644 index 000000000000..6f783da74561 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Sensor.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Sensor data + /// + public partial class Sensor + { + /// + /// Initializes a new instance of the Sensor class. + /// + public Sensor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Sensor class. + /// + /// Sensor name + /// Zone Name. + public Sensor(string name = default(string), string zone = default(string)) + { + Name = name; + Zone = zone; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets sensor name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets zone Name. + /// + [JsonProperty(PropertyName = "zone")] + public string Zone { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ServicePrincipalProperties.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ServicePrincipalProperties.cs new file mode 100644 index 000000000000..974632976de4 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ServicePrincipalProperties.cs @@ -0,0 +1,64 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of the service principal. + /// + public partial class ServicePrincipalProperties + { + /// + /// Initializes a new instance of the ServicePrincipalProperties class. + /// + public ServicePrincipalProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServicePrincipalProperties class. + /// + /// Application ID of service + /// principal. + /// A secret string that the application uses to + /// prove its identity, also can be referred to as application password + /// (write only). + public ServicePrincipalProperties(string applicationId = default(string), string secret = default(string)) + { + ApplicationId = applicationId; + Secret = secret; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets application ID of service principal. + /// + [JsonProperty(PropertyName = "applicationId")] + public string ApplicationId { get; set; } + + /// + /// Gets or sets a secret string that the application uses to prove its + /// identity, also can be referred to as application password (write + /// only). + /// + [JsonProperty(PropertyName = "secret")] + public string Secret { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Site.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Site.cs new file mode 100644 index 000000000000..1d6c9cdc2106 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/Site.cs @@ -0,0 +1,51 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Site data + /// + public partial class Site + { + /// + /// Initializes a new instance of the Site class. + /// + public Site() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Site class. + /// + /// Site display name + public Site(string displayName = default(string)) + { + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets site display name + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SuppressionAlertsScope.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SuppressionAlertsScope.cs new file mode 100644 index 000000000000..e60a2338735c --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/SuppressionAlertsScope.cs @@ -0,0 +1,66 @@ +// +// 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.Security.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class SuppressionAlertsScope + { + /// + /// Initializes a new instance of the SuppressionAlertsScope class. + /// + public SuppressionAlertsScope() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SuppressionAlertsScope class. + /// + /// All the conditions inside need to be true in + /// order to suppress the alert + public SuppressionAlertsScope(IList allOf) + { + AllOf = allOf; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets all the conditions inside need to be true in order to + /// suppress the alert + /// + [JsonProperty(PropertyName = "allOf")] + public IList AllOf { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AllOf == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AllOf"); + } + } + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ThresholdCustomAlertRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ThresholdCustomAlertRule.cs index 7df8da76196b..47f1dfdf2e8f 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ThresholdCustomAlertRule.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/ThresholdCustomAlertRule.cs @@ -17,7 +17,6 @@ namespace Microsoft.Azure.Management.Security.Models /// A custom alert rule that checks if a value (depends on the custom alert /// type) is within the given range. /// - [Newtonsoft.Json.JsonObject("ThresholdCustomAlertRule")] public partial class ThresholdCustomAlertRule : CustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TimeWindowCustomAlertRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TimeWindowCustomAlertRule.cs index eaeb685da1b5..e6fdc3230f94 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TimeWindowCustomAlertRule.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TimeWindowCustomAlertRule.cs @@ -17,7 +17,6 @@ namespace Microsoft.Azure.Management.Security.Models /// A custom alert rule that checks if the number of activities (depends on /// the custom alert type) in a time window is within the given range. /// - [Newtonsoft.Json.JsonObject("TimeWindowCustomAlertRule")] public partial class TimeWindowCustomAlertRule : ThresholdCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TrackedResource.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TrackedResource.cs index 0eda4aeb3d48..c2c25e9adf7a 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TrackedResource.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TrackedResource.cs @@ -77,10 +77,10 @@ public TrackedResource() public string Type { get; private set; } /// - /// Gets location where the resource is stored + /// Gets or sets location where the resource is stored /// [JsonProperty(PropertyName = "location")] - public string Location { get; private set; } + public string Location { get; set; } /// /// Gets or sets kind of the resource diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TwinUpdatesNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TwinUpdatesNotInAllowedRange.cs index e0b4415251e9..047ed484cb7e 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TwinUpdatesNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/TwinUpdatesNotInAllowedRange.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of twin updates is not in allowed range. /// - [Newtonsoft.Json.JsonObject("TwinUpdatesNotInAllowedRange")] public partial class TwinUpdatesNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/UnauthorizedOperationsNotInAllowedRange.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/UnauthorizedOperationsNotInAllowedRange.cs index f57c05fd4648..757b89fe6a5f 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/UnauthorizedOperationsNotInAllowedRange.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/UnauthorizedOperationsNotInAllowedRange.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.Security.Models { - using Newtonsoft.Json; using System.Linq; /// /// Number of unauthorized operations is not in allowed range. /// - [Newtonsoft.Json.JsonObject("UnauthorizedOperationsNotInAllowedRange")] public partial class UnauthorizedOperationsNotInAllowedRange : TimeWindowCustomAlertRule { /// diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VaRule.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VaRule.cs new file mode 100644 index 000000000000..8aa624d21d9a --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VaRule.cs @@ -0,0 +1,119 @@ +// +// 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.Security.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// vulnerability assessment rule metadata details. + /// + public partial class VaRule + { + /// + /// Initializes a new instance of the VaRule class. + /// + public VaRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VaRule class. + /// + /// The rule Id. + /// Possible values include: 'High', 'Medium', + /// 'Low', 'Informational', 'Obsolete' + /// The rule category. + /// Possible values include: 'Binary', + /// 'BaselineExpected', 'PositiveList', 'NegativeList' + /// The rule title. + /// The rule description. + /// The rule rationale. + /// The benchmark references. + public VaRule(string ruleId = default(string), string severity = default(string), string category = default(string), string ruleType = default(string), string title = default(string), string description = default(string), string rationale = default(string), QueryCheck queryCheck = default(QueryCheck), IList benchmarkReferences = default(IList)) + { + RuleId = ruleId; + Severity = severity; + Category = category; + RuleType = ruleType; + Title = title; + Description = description; + Rationale = rationale; + QueryCheck = queryCheck; + BenchmarkReferences = benchmarkReferences; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the rule Id. + /// + [JsonProperty(PropertyName = "ruleId")] + public string RuleId { get; set; } + + /// + /// Gets or sets possible values include: 'High', 'Medium', 'Low', + /// 'Informational', 'Obsolete' + /// + [JsonProperty(PropertyName = "severity")] + public string Severity { get; set; } + + /// + /// Gets or sets the rule category. + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } + + /// + /// Gets or sets possible values include: 'Binary', 'BaselineExpected', + /// 'PositiveList', 'NegativeList' + /// + [JsonProperty(PropertyName = "ruleType")] + public string RuleType { get; set; } + + /// + /// Gets or sets the rule title. + /// + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or sets the rule description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets the rule rationale. + /// + [JsonProperty(PropertyName = "rationale")] + public string Rationale { get; set; } + + /// + /// + [JsonProperty(PropertyName = "queryCheck")] + public QueryCheck QueryCheck { get; set; } + + /// + /// Gets or sets the benchmark references. + /// + [JsonProperty(PropertyName = "benchmarkReferences")] + public IList BenchmarkReferences { get; set; } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VersionKind.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VersionKind.cs new file mode 100644 index 000000000000..a65157494913 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VersionKind.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + + /// + /// Defines values for VersionKind. + /// + public static class VersionKind + { + public const string Latest = "Latest"; + public const string Previous = "Previous"; + public const string Preview = "Preview"; + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VmRecommendation.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VmRecommendation.cs index 206e32e66de3..d9ffe6372bac 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VmRecommendation.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/Models/VmRecommendation.cs @@ -14,7 +14,7 @@ namespace Microsoft.Azure.Management.Security.Models using System.Linq; /// - /// Represents a machine that is part of a VM/server group + /// Represents a machine that is part of a machine group /// public partial class VmRecommendation { diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/OnPremiseIotSensorsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/OnPremiseIotSensorsOperations.cs new file mode 100644 index 000000000000..256212b665bc --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/OnPremiseIotSensorsOperations.cs @@ -0,0 +1,990 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// OnPremiseIotSensorsOperations operations. + /// + internal partial class OnPremiseIotSensorsOperations : IServiceOperations, IOnPremiseIotSensorsOperations + { + /// + /// Initializes a new instance of the OnPremiseIotSensorsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal OnPremiseIotSensorsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List on-premise IoT sensors + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/onPremiseIotSensors").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get on-premise IoT sensor + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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 onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (onPremiseIotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "onPremiseIotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("onPremiseIotSensorName", onPremiseIotSensorName); + 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}/providers/Microsoft.Security/onPremiseIotSensors/{onPremiseIotSensorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{onPremiseIotSensorName}", System.Uri.EscapeDataString(onPremiseIotSensorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update on-premise IoT sensor + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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 onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (onPremiseIotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "onPremiseIotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("onPremiseIotSensorName", onPremiseIotSensorName); + 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}/providers/Microsoft.Security/onPremiseIotSensors/{onPremiseIotSensorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{onPremiseIotSensorName}", System.Uri.EscapeDataString(onPremiseIotSensorName)); + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete on-premise IoT sensor + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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 onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (onPremiseIotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "onPremiseIotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("onPremiseIotSensorName", onPremiseIotSensorName); + 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}/providers/Microsoft.Security/onPremiseIotSensors/{onPremiseIotSensorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{onPremiseIotSensorName}", System.Uri.EscapeDataString(onPremiseIotSensorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Download sensor activation file + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// 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> DownloadActivationWithHttpMessagesAsync(string onPremiseIotSensorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (onPremiseIotSensorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "onPremiseIotSensorName"); + } + string apiVersion = "2020-08-06-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("onPremiseIotSensorName", onPremiseIotSensorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DownloadActivation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/onPremiseIotSensors/{onPremiseIotSensorName}/downloadActivation").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{onPremiseIotSensorName}", System.Uri.EscapeDataString(onPremiseIotSensorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/OnPremiseIotSensorsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/OnPremiseIotSensorsOperationsExtensions.cs new file mode 100644 index 000000000000..47615b98c03c --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/OnPremiseIotSensorsOperationsExtensions.cs @@ -0,0 +1,186 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.IO; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for OnPremiseIotSensorsOperations. + /// + public static partial class OnPremiseIotSensorsOperationsExtensions + { + /// + /// List on-premise IoT sensors + /// + /// + /// The operations group for this extension method. + /// + public static OnPremiseIotSensorsList List(this IOnPremiseIotSensorsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List on-premise IoT sensors + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IOnPremiseIotSensorsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get on-premise IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + public static OnPremiseIotSensor Get(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName) + { + return operations.GetAsync(onPremiseIotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Get on-premise IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(onPremiseIotSensorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update on-premise IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + public static OnPremiseIotSensor CreateOrUpdate(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName) + { + return operations.CreateOrUpdateAsync(onPremiseIotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Create or update on-premise IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(onPremiseIotSensorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete on-premise IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + public static void Delete(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName) + { + operations.DeleteAsync(onPremiseIotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Delete on-premise IoT sensor + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(onPremiseIotSensorName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Download sensor activation file + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + public static Stream DownloadActivation(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName) + { + return operations.DownloadActivationAsync(onPremiseIotSensorName).GetAwaiter().GetResult(); + } + + /// + /// Download sensor activation file + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the on-premise IoT sensor + /// + /// + /// The cancellation token. + /// + public static async Task DownloadActivationAsync(this IOnPremiseIotSensorsOperations operations, string onPremiseIotSensorName, CancellationToken cancellationToken = default(CancellationToken)) + { + var _result = await operations.DownloadActivationWithHttpMessagesAsync(onPremiseIotSensorName, null, cancellationToken).ConfigureAwait(false); + _result.Request.Dispose(); + return _result.Body; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SdkInfo_SecurityCenter.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SdkInfo_SecurityCenter.cs index bfad44a62e9e..7f044766b343 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SdkInfo_SecurityCenter.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SdkInfo_SecurityCenter.cs @@ -22,7 +22,8 @@ public static IEnumerable> ApiInfo_SecurityCenter new Tuple("Security", "AdaptiveApplicationControls", "2020-01-01"), new Tuple("Security", "AdaptiveNetworkHardenings", "2020-01-01"), new Tuple("Security", "AdvancedThreatProtection", "2019-01-01"), - new Tuple("Security", "Alerts", "2019-01-01"), + new Tuple("Security", "Alerts", "2020-01-01"), + new Tuple("Security", "AlertsSuppressionRules", "2019-01-01-preview"), new Tuple("Security", "AllowedConnections", "2020-01-01"), new Tuple("Security", "Assessments", "2020-01-01"), new Tuple("Security", "AssessmentsMetadata", "2020-01-01"), @@ -30,41 +31,54 @@ public static IEnumerable> ApiInfo_SecurityCenter new Tuple("Security", "Automations", "2019-01-01-preview"), new Tuple("Security", "ComplianceResults", "2017-08-01"), new Tuple("Security", "Compliances", "2017-08-01-preview"), + new Tuple("Security", "Connectors", "2020-01-01-preview"), + new Tuple("Security", "Device", "2020-08-06-preview"), new Tuple("Security", "DeviceSecurityGroups", "2019-08-01"), - new Tuple("Security", "DiscoveredSecuritySolutions", "2015-06-01-preview"), - new Tuple("Security", "ExternalSecuritySolutions", "2015-06-01-preview"), + new Tuple("Security", "DevicesForHub", "2020-08-06-preview"), + new Tuple("Security", "DevicesForSubscription", "2020-08-06-preview"), + new Tuple("Security", "DiscoveredSecuritySolutions", "2020-01-01"), + new Tuple("Security", "ExternalSecuritySolutions", "2020-01-01"), new Tuple("Security", "InformationProtectionPolicies", "2017-08-01-preview"), + new Tuple("Security", "IotAlertTypes", "2019-08-01"), + new Tuple("Security", "IotAlertTypes", "2020-08-06-preview"), + new Tuple("Security", "IotAlerts", "2019-08-01"), + new Tuple("Security", "IotAlerts", "2020-08-06-preview"), + new Tuple("Security", "IotDefenderSettings", "2020-08-06-preview"), + new Tuple("Security", "IotRecommendationTypes", "2019-08-01"), + new Tuple("Security", "IotRecommendationTypes", "2020-08-06-preview"), + new Tuple("Security", "IotRecommendations", "2019-08-01"), + new Tuple("Security", "IotRecommendations", "2020-08-06-preview"), new Tuple("Security", "IotSecuritySolution", "2019-08-01"), new Tuple("Security", "IotSecuritySolutionAnalytics", "2019-08-01"), new Tuple("Security", "IotSecuritySolutionsAnalyticsAggregatedAlert", "2019-08-01"), new Tuple("Security", "IotSecuritySolutionsAnalyticsRecommendation", "2019-08-01"), + new Tuple("Security", "IotSensors", "2020-08-06-preview"), new Tuple("Security", "JitNetworkAccessPolicies", "2020-01-01"), new Tuple("Security", "Locations", "2015-06-01-preview"), + new Tuple("Security", "OnPremiseIotSensors", "2020-08-06-preview"), new Tuple("Security", "Operations", "2015-06-01-preview"), new Tuple("Security", "Pricings", "2018-06-01"), new Tuple("Security", "RegulatoryComplianceAssessments", "2019-01-01-preview"), new Tuple("Security", "RegulatoryComplianceControls", "2019-01-01-preview"), new Tuple("Security", "RegulatoryComplianceStandards", "2019-01-01-preview"), + new Tuple("Security", "SecureScoreControlDefinitions", "2020-01-01"), + new Tuple("Security", "SecureScoreControls", "2020-01-01"), + new Tuple("Security", "SecureScores", "2020-01-01"), new Tuple("Security", "SecurityContacts", "2017-08-01-preview"), - new Tuple("Security", "ServerVulnerabilityAssessment", "2019-01-01-preview"), + new Tuple("Security", "SecuritySolutions", "2020-01-01"), + new Tuple("Security", "SecuritySolutionsReferenceData", "2020-01-01"), + new Tuple("Security", "ServerVulnerabilityAssessment", "2020-01-01"), new Tuple("Security", "Settings", "2019-01-01"), + new Tuple("Security", "SqlVulnerabilityAssessmentBaselineRules", "2020-07-01-preview"), + new Tuple("Security", "SqlVulnerabilityAssessmentScanResults", "2020-07-01-preview"), + new Tuple("Security", "SqlVulnerabilityAssessmentScans", "2020-07-01-preview"), new Tuple("Security", "SubAssessments", "2019-01-01-preview"), new Tuple("Security", "Tasks", "2015-06-01-preview"), new Tuple("Security", "Topology", "2020-01-01"), new Tuple("Security", "WorkspaceSettings", "2017-08-01-preview"), + new Tuple("Security", "securitySolutionsReferenceData", "2020-01-01"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "(empty)"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/security/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\\GitHub\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "4bfc60521b88d21c9cd4c44cc367e080ecc4af81"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlDefinitionsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlDefinitionsOperations.cs new file mode 100644 index 000000000000..d0504ab34dcd --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlDefinitionsOperations.cs @@ -0,0 +1,750 @@ +// +// 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.Security +{ + 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; + + /// + /// SecureScoreControlDefinitionsOperations operations. + /// + internal partial class SecureScoreControlDefinitionsOperations : IServiceOperations, ISecureScoreControlDefinitionsOperations + { + /// + /// Initializes a new instance of the SecureScoreControlDefinitionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecureScoreControlDefinitionsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List the available security controls, their assessments, and the max score + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Security/secureScoreControlDefinitions").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// For a specified subscription, list the available security controls, their + /// assessments, and the max score + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the available security controls, their assessments, and the max score + /// + /// + /// 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// For a specified subscription, list the available security controls, their + /// assessments, and the max score + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlDefinitionsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlDefinitionsOperationsExtensions.cs new file mode 100644 index 000000000000..dd3871951067 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlDefinitionsOperationsExtensions.cs @@ -0,0 +1,153 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecureScoreControlDefinitionsOperations. + /// + public static partial class SecureScoreControlDefinitionsOperationsExtensions + { + /// + /// List the available security controls, their assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this ISecureScoreControlDefinitionsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List the available security controls, their assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISecureScoreControlDefinitionsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// For a specified subscription, list the available security controls, their + /// assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListBySubscription(this ISecureScoreControlDefinitionsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// For a specified subscription, list the available security controls, their + /// assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this ISecureScoreControlDefinitionsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the available security controls, their assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISecureScoreControlDefinitionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List the available security controls, their assessments, and the max score + /// + /// + /// 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 ISecureScoreControlDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// For a specified subscription, list the available security controls, their + /// assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this ISecureScoreControlDefinitionsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// For a specified subscription, list the available security controls, their + /// assessments, and the max score + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this ISecureScoreControlDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlsOperations.cs new file mode 100644 index 000000000000..68b0ca1ac12f --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlsOperations.cs @@ -0,0 +1,792 @@ +// +// 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.Security +{ + 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; + + /// + /// SecureScoreControlsOperations operations. + /// + internal partial class SecureScoreControlsOperations : IServiceOperations, ISecureScoreControlsOperations + { + /// + /// Initializes a new instance of the SecureScoreControlsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecureScoreControlsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' as in + /// the sample request below. + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + /// + /// 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>> ListBySecureScoreWithHttpMessagesAsync(string secureScoreName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (secureScoreName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secureScoreName"); + } + string apiVersion = "2020-01-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("secureScoreName", secureScoreName); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySecureScore", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{secureScoreName}", System.Uri.EscapeDataString(secureScoreName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all security controls within a scope + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-01-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("expand", expand); + 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.Security/secureScoreControls").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 (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// 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>> ListBySecureScoreNextWithHttpMessagesAsync(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, "ListBySecureScoreNext", 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all security controls within a scope + /// + /// + /// 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlsOperationsExtensions.cs new file mode 100644 index 000000000000..103f6984f1c7 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoreControlsOperationsExtensions.cs @@ -0,0 +1,169 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecureScoreControlsOperations. + /// + public static partial class SecureScoreControlsOperationsExtensions + { + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' as in + /// the sample request below. + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + public static IPage ListBySecureScore(this ISecureScoreControlsOperations operations, string secureScoreName, string expand = default(string)) + { + return operations.ListBySecureScoreAsync(secureScoreName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' as in + /// the sample request below. + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySecureScoreAsync(this ISecureScoreControlsOperations operations, string secureScoreName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySecureScoreWithHttpMessagesAsync(secureScoreName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all security controls within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + public static IPage List(this ISecureScoreControlsOperations operations, string expand = default(string)) + { + return operations.ListAsync(expand).GetAwaiter().GetResult(); + } + + /// + /// Get all security controls within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData expand. Optional. Possible values include: 'definition' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISecureScoreControlsOperations operations, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySecureScoreNext(this ISecureScoreControlsOperations operations, string nextPageLink) + { + return operations.ListBySecureScoreNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all security controls for a specific initiative within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySecureScoreNextAsync(this ISecureScoreControlsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySecureScoreNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all security controls within a scope + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISecureScoreControlsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all security controls within a scope + /// + /// + /// 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 ISecureScoreControlsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoresOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoresOperations.cs new file mode 100644 index 000000000000..4c2a94f4f1e5 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoresOperations.cs @@ -0,0 +1,606 @@ +// +// 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.Security +{ + 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; + + /// + /// SecureScoresOperations operations. + /// + internal partial class SecureScoresOperations : IServiceOperations, ISecureScoresOperations + { + /// + /// Initializes a new instance of the SecureScoresOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecureScoresOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// List secure scores for all your Security Center initiatives within your + /// current scope. + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get secure score for a specific Security Center initiative within your + /// current scope. For the ASC Default initiative, use 'ascScore'. + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' as in + /// the sample request below. + /// + /// + /// 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 secureScoreName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (secureScoreName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secureScoreName"); + } + string apiVersion = "2020-01-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("secureScoreName", secureScoreName); + 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}/providers/Microsoft.Security/secureScores/{secureScoreName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{secureScoreName}", System.Uri.EscapeDataString(secureScoreName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List secure scores for all your Security Center initiatives within your + /// current scope. + /// + /// + /// 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoresOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoresOperationsExtensions.cs new file mode 100644 index 000000000000..8429cf06bf15 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecureScoresOperationsExtensions.cs @@ -0,0 +1,129 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecureScoresOperations. + /// + public static partial class SecureScoresOperationsExtensions + { + /// + /// List secure scores for all your Security Center initiatives within your + /// current scope. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this ISecureScoresOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List secure scores for all your Security Center initiatives within your + /// current scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISecureScoresOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get secure score for a specific Security Center initiative within your + /// current scope. For the ASC Default initiative, use 'ascScore'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' as in + /// the sample request below. + /// + public static SecureScoreItem Get(this ISecureScoresOperations operations, string secureScoreName) + { + return operations.GetAsync(secureScoreName).GetAwaiter().GetResult(); + } + + /// + /// Get secure score for a specific Security Center initiative within your + /// current scope. For the ASC Default initiative, use 'ascScore'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The initiative name. For the ASC Default initiative, use 'ascScore' as in + /// the sample request below. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISecureScoresOperations operations, string secureScoreName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(secureScoreName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List secure scores for all your Security Center initiatives within your + /// current scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISecureScoresOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List secure scores for all your Security Center initiatives within your + /// current scope. + /// + /// + /// 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 ISecureScoresOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecurityCenterClient.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecurityCenterClient.cs index 0e35f6fcf55a..fa6209f9af3b 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecurityCenterClient.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecurityCenterClient.cs @@ -86,11 +86,6 @@ public partial class SecurityCenterClient : ServiceClient, /// public virtual IPricingsOperations Pricings { get; private set; } - /// - /// Gets the IAlertsOperations. - /// - public virtual IAlertsOperations Alerts { get; private set; } - /// /// Gets the ISettingsOperations. /// @@ -127,14 +122,24 @@ public partial class SecurityCenterClient : ServiceClient, public virtual IIotSecuritySolutionsAnalyticsRecommendationOperations IotSecuritySolutionsAnalyticsRecommendation { get; private set; } /// - /// Gets the IDiscoveredSecuritySolutionsOperations. + /// Gets the IIotAlertTypesOperations. /// - public virtual IDiscoveredSecuritySolutionsOperations DiscoveredSecuritySolutions { get; private set; } + public virtual IIotAlertTypesOperations IotAlertTypes { get; private set; } /// - /// Gets the IExternalSecuritySolutionsOperations. + /// Gets the IIotAlertsOperations. /// - public virtual IExternalSecuritySolutionsOperations ExternalSecuritySolutions { get; private set; } + public virtual IIotAlertsOperations IotAlerts { get; private set; } + + /// + /// Gets the IIotRecommendationTypesOperations. + /// + public virtual IIotRecommendationTypesOperations IotRecommendationTypes { get; private set; } + + /// + /// Gets the IIotRecommendationsOperations. + /// + public virtual IIotRecommendationsOperations IotRecommendations { get; private set; } /// /// Gets the ILocationsOperations. @@ -191,11 +196,6 @@ public partial class SecurityCenterClient : ServiceClient, /// public virtual IRegulatoryComplianceAssessmentsOperations RegulatoryComplianceAssessments { get; private set; } - /// - /// Gets the IServerVulnerabilityAssessmentOperations. - /// - public virtual IServerVulnerabilityAssessmentOperations ServerVulnerabilityAssessment { get; private set; } - /// /// Gets the ISubAssessmentsOperations. /// @@ -206,6 +206,16 @@ public partial class SecurityCenterClient : ServiceClient, /// public virtual IAutomationsOperations Automations { get; private set; } + /// + /// Gets the IAlertsSuppressionRulesOperations. + /// + public virtual IAlertsSuppressionRulesOperations AlertsSuppressionRules { get; private set; } + + /// + /// Gets the IServerVulnerabilityAssessmentOperations. + /// + public virtual IServerVulnerabilityAssessmentOperations ServerVulnerabilityAssessment { get; private set; } + /// /// Gets the IAssessmentsMetadataOperations. /// @@ -236,11 +246,101 @@ public partial class SecurityCenterClient : ServiceClient, /// public virtual ITopologyOperations Topology { get; private set; } + /// + /// Gets the IAlertsOperations. + /// + public virtual IAlertsOperations Alerts { get; private set; } + /// /// Gets the IJitNetworkAccessPoliciesOperations. /// public virtual IJitNetworkAccessPoliciesOperations JitNetworkAccessPolicies { get; private set; } + /// + /// Gets the IDiscoveredSecuritySolutionsOperations. + /// + public virtual IDiscoveredSecuritySolutionsOperations DiscoveredSecuritySolutions { get; private set; } + + /// + /// Gets the ISecuritySolutionsReferenceDataOperations. + /// + public virtual ISecuritySolutionsReferenceDataOperations SecuritySolutionsReferenceData { get; private set; } + + /// + /// Gets the IExternalSecuritySolutionsOperations. + /// + public virtual IExternalSecuritySolutionsOperations ExternalSecuritySolutions { get; private set; } + + /// + /// Gets the ISecureScoresOperations. + /// + public virtual ISecureScoresOperations SecureScores { get; private set; } + + /// + /// Gets the ISecureScoreControlsOperations. + /// + public virtual ISecureScoreControlsOperations SecureScoreControls { get; private set; } + + /// + /// Gets the ISecureScoreControlDefinitionsOperations. + /// + public virtual ISecureScoreControlDefinitionsOperations SecureScoreControlDefinitions { get; private set; } + + /// + /// Gets the ISecuritySolutionsOperations. + /// + public virtual ISecuritySolutionsOperations SecuritySolutions { get; private set; } + + /// + /// Gets the IConnectorsOperations. + /// + public virtual IConnectorsOperations Connectors { get; private set; } + + /// + /// Gets the ISqlVulnerabilityAssessmentScansOperations. + /// + public virtual ISqlVulnerabilityAssessmentScansOperations SqlVulnerabilityAssessmentScans { get; private set; } + + /// + /// Gets the ISqlVulnerabilityAssessmentScanResultsOperations. + /// + public virtual ISqlVulnerabilityAssessmentScanResultsOperations SqlVulnerabilityAssessmentScanResults { get; private set; } + + /// + /// Gets the ISqlVulnerabilityAssessmentBaselineRulesOperations. + /// + public virtual ISqlVulnerabilityAssessmentBaselineRulesOperations SqlVulnerabilityAssessmentBaselineRules { get; private set; } + + /// + /// Gets the IIotDefenderSettingsOperations. + /// + public virtual IIotDefenderSettingsOperations IotDefenderSettings { get; private set; } + + /// + /// Gets the IIotSensorsOperations. + /// + public virtual IIotSensorsOperations IotSensors { get; private set; } + + /// + /// Gets the IDevicesForSubscriptionOperations. + /// + public virtual IDevicesForSubscriptionOperations DevicesForSubscription { get; private set; } + + /// + /// Gets the IDevicesForHubOperations. + /// + public virtual IDevicesForHubOperations DevicesForHub { get; private set; } + + /// + /// Gets the IDeviceOperations. + /// + public virtual IDeviceOperations Device { get; private set; } + + /// + /// Gets the IOnPremiseIotSensorsOperations. + /// + public virtual IOnPremiseIotSensorsOperations OnPremiseIotSensors { get; private set; } + /// /// Initializes a new instance of the SecurityCenterClient class. /// @@ -484,7 +584,6 @@ private void Initialize() { ComplianceResults = new ComplianceResultsOperations(this); Pricings = new PricingsOperations(this); - Alerts = new AlertsOperations(this); Settings = new SettingsOperations(this); AdvancedThreatProtection = new AdvancedThreatProtectionOperations(this); DeviceSecurityGroups = new DeviceSecurityGroupsOperations(this); @@ -492,8 +591,10 @@ private void Initialize() IotSecuritySolutionAnalytics = new IotSecuritySolutionAnalyticsOperations(this); IotSecuritySolutionsAnalyticsAggregatedAlert = new IotSecuritySolutionsAnalyticsAggregatedAlertOperations(this); IotSecuritySolutionsAnalyticsRecommendation = new IotSecuritySolutionsAnalyticsRecommendationOperations(this); - DiscoveredSecuritySolutions = new DiscoveredSecuritySolutionsOperations(this); - ExternalSecuritySolutions = new ExternalSecuritySolutionsOperations(this); + IotAlertTypes = new IotAlertTypesOperations(this); + IotAlerts = new IotAlertsOperations(this); + IotRecommendationTypes = new IotRecommendationTypesOperations(this); + IotRecommendations = new IotRecommendationsOperations(this); Locations = new LocationsOperations(this); Operations = new Operations(this); Tasks = new TasksOperations(this); @@ -505,16 +606,35 @@ private void Initialize() RegulatoryComplianceStandards = new RegulatoryComplianceStandardsOperations(this); RegulatoryComplianceControls = new RegulatoryComplianceControlsOperations(this); RegulatoryComplianceAssessments = new RegulatoryComplianceAssessmentsOperations(this); - ServerVulnerabilityAssessment = new ServerVulnerabilityAssessmentOperations(this); SubAssessments = new SubAssessmentsOperations(this); Automations = new AutomationsOperations(this); + AlertsSuppressionRules = new AlertsSuppressionRulesOperations(this); + ServerVulnerabilityAssessment = new ServerVulnerabilityAssessmentOperations(this); AssessmentsMetadata = new AssessmentsMetadataOperations(this); Assessments = new AssessmentsOperations(this); AdaptiveApplicationControls = new AdaptiveApplicationControlsOperations(this); AdaptiveNetworkHardenings = new AdaptiveNetworkHardeningsOperations(this); AllowedConnections = new AllowedConnectionsOperations(this); Topology = new TopologyOperations(this); + Alerts = new AlertsOperations(this); JitNetworkAccessPolicies = new JitNetworkAccessPoliciesOperations(this); + DiscoveredSecuritySolutions = new DiscoveredSecuritySolutionsOperations(this); + SecuritySolutionsReferenceData = new SecuritySolutionsReferenceDataOperations(this); + ExternalSecuritySolutions = new ExternalSecuritySolutionsOperations(this); + SecureScores = new SecureScoresOperations(this); + SecureScoreControls = new SecureScoreControlsOperations(this); + SecureScoreControlDefinitions = new SecureScoreControlDefinitionsOperations(this); + SecuritySolutions = new SecuritySolutionsOperations(this); + Connectors = new ConnectorsOperations(this); + SqlVulnerabilityAssessmentScans = new SqlVulnerabilityAssessmentScansOperations(this); + SqlVulnerabilityAssessmentScanResults = new SqlVulnerabilityAssessmentScanResultsOperations(this); + SqlVulnerabilityAssessmentBaselineRules = new SqlVulnerabilityAssessmentBaselineRulesOperations(this); + IotDefenderSettings = new IotDefenderSettingsOperations(this); + IotSensors = new IotSensorsOperations(this); + DevicesForSubscription = new DevicesForSubscriptionOperations(this); + DevicesForHub = new DevicesForHubOperations(this); + Device = new DeviceOperations(this); + OnPremiseIotSensors = new OnPremiseIotSensorsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; @@ -549,14 +669,18 @@ private void Initialize() DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("kind")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("ruleType")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("ruleType")); - SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("kind")); - DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("kind")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("source")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("source")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("assessedResourceType")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("assessedResourceType")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("actionType")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("actionType")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("kind")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("kind")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("authenticationType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("authenticationType")); CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsOperations.cs new file mode 100644 index 000000000000..de7706e3ffbb --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsOperations.cs @@ -0,0 +1,632 @@ +// +// 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.Security +{ + 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; + + /// + /// SecuritySolutionsOperations operations. + /// + internal partial class SecuritySolutionsOperations : IServiceOperations, ISecuritySolutionsOperations + { + /// + /// Initializes a new instance of the SecuritySolutionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecuritySolutionsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Gets a list of Security Solutions for the subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a specific Security Solution. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// Name of security solution. + /// + /// + /// 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 securitySolutionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.AscLocation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); + } + if (securitySolutionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securitySolutionName"); + } + string apiVersion = "2020-01-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("securitySolutionName", securitySolutionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ascLocation}", System.Uri.EscapeDataString(Client.AscLocation)); + _url = _url.Replace("{securitySolutionName}", System.Uri.EscapeDataString(securitySolutionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of Security Solutions for 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsOperationsExtensions.cs new file mode 100644 index 000000000000..cceb5464c183 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsOperationsExtensions.cs @@ -0,0 +1,129 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecuritySolutionsOperations. + /// + public static partial class SecuritySolutionsOperationsExtensions + { + /// + /// Gets a list of Security Solutions for the subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this ISecuritySolutionsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of Security Solutions for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISecuritySolutionsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a specific Security Solution. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// Name of security solution. + /// + public static SecuritySolution Get(this ISecuritySolutionsOperations operations, string resourceGroupName, string securitySolutionName) + { + return operations.GetAsync(resourceGroupName, securitySolutionName).GetAwaiter().GetResult(); + } + + /// + /// Gets a specific Security Solution. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. The name is + /// case insensitive. + /// + /// + /// Name of security solution. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISecuritySolutionsOperations operations, string resourceGroupName, string securitySolutionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, securitySolutionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of Security Solutions for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISecuritySolutionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of Security Solutions for 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 ISecuritySolutionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsReferenceDataOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsReferenceDataOperations.cs new file mode 100644 index 000000000000..c71d1fe5707a --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsReferenceDataOperations.cs @@ -0,0 +1,426 @@ +// +// 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.Security +{ + 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; + + /// + /// SecuritySolutionsReferenceDataOperations operations. + /// + internal partial class SecuritySolutionsReferenceDataOperations : IServiceOperations, ISecuritySolutionsReferenceDataOperations + { + /// + /// Initializes a new instance of the SecuritySolutionsReferenceDataOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecuritySolutionsReferenceDataOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Gets a list of all supported Security Solutions for the subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets list of all supported Security Solutions for subscription and + /// location. + /// + /// + /// 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> ListByHomeRegionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Client.SubscriptionId, "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$")) + { + throw new ValidationException(ValidationRules.Pattern, "Client.SubscriptionId", "^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$"); + } + } + if (Client.AscLocation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.AscLocation"); + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByHomeRegion", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{ascLocation}", System.Uri.EscapeDataString(Client.AscLocation)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsReferenceDataOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsReferenceDataOperationsExtensions.cs new file mode 100644 index 000000000000..9209ab0f8048 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SecuritySolutionsReferenceDataOperationsExtensions.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecuritySolutionsReferenceDataOperations. + /// + public static partial class SecuritySolutionsReferenceDataOperationsExtensions + { + /// + /// Gets a list of all supported Security Solutions for the subscription. + /// + /// + /// The operations group for this extension method. + /// + public static SecuritySolutionsReferenceDataList List(this ISecuritySolutionsReferenceDataOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of all supported Security Solutions for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this ISecuritySolutionsReferenceDataOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets list of all supported Security Solutions for subscription and + /// location. + /// + /// + /// The operations group for this extension method. + /// + public static SecuritySolutionsReferenceDataList ListByHomeRegion(this ISecuritySolutionsReferenceDataOperations operations) + { + return operations.ListByHomeRegionAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets list of all supported Security Solutions for subscription and + /// location. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task ListByHomeRegionAsync(this ISecuritySolutionsReferenceDataOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByHomeRegionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ServerVulnerabilityAssessmentOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ServerVulnerabilityAssessmentOperations.cs index 46ac7bbde995..01d9a79676f6 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ServerVulnerabilityAssessmentOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/ServerVulnerabilityAssessmentOperations.cs @@ -132,7 +132,7 @@ internal ServerVulnerabilityAssessmentOperations(SecurityCenterClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); } - string apiVersion = "2019-01-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -369,7 +369,7 @@ internal ServerVulnerabilityAssessmentOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); } string serverVulnerabilityAssessment = "default"; - string apiVersion = "2019-01-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -608,7 +608,7 @@ internal ServerVulnerabilityAssessmentOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); } string serverVulnerabilityAssessment = "default"; - string apiVersion = "2019-01-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -843,7 +843,7 @@ internal ServerVulnerabilityAssessmentOperations(SecurityCenterClient client) throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); } string serverVulnerabilityAssessment = "default"; - string apiVersion = "2019-01-01-preview"; + string apiVersion = "2020-01-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentBaselineRulesOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentBaselineRulesOperations.cs new file mode 100644 index 000000000000..a73d325a2059 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentBaselineRulesOperations.cs @@ -0,0 +1,1094 @@ +// +// 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.Security +{ + 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; + + /// + /// SqlVulnerabilityAssessmentBaselineRulesOperations operations. + /// + internal partial class SqlVulnerabilityAssessmentBaselineRulesOperations : IServiceOperations, ISqlVulnerabilityAssessmentBaselineRulesOperations + { + /// + /// Initializes a new instance of the SqlVulnerabilityAssessmentBaselineRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SqlVulnerabilityAssessmentBaselineRulesOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Creates a Baseline for a rule in a database. Will overwrite any previously + /// existing results. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + /// + /// 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 ruleId, string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IList> results = default(IList>), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ruleId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleId"); + } + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + RuleResultsInput body = default(RuleResultsInput); + if (latestScan != null || results != null) + { + body = new RuleResultsInput(); + body.LatestScan = latestScan; + body.Results = results; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("ruleId", ruleId); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("body", body); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}").ToString(); + _url = _url.Replace("{ruleId}", System.Uri.EscapeDataString(ruleId)); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the results for a given rule in the Baseline. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 ruleId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ruleId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleId"); + } + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("ruleId", ruleId); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}").ToString(); + _url = _url.Replace("{ruleId}", System.Uri.EscapeDataString(ruleId)); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a rule from the Baseline of a given database. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 ruleId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ruleId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleId"); + } + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("ruleId", ruleId); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}").ToString(); + _url = _url.Replace("{ruleId}", System.Uri.EscapeDataString(ruleId)); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the results for all rules in the Baseline. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Add a list of baseline rules. Will overwrite any previously existing + /// results (for all rules). + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + /// + /// 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> AddWithHttpMessagesAsync(string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IDictionary>> results = default(IDictionary>>), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + RulesResultsInput body = default(RulesResultsInput); + if (latestScan != null || results != null) + { + body = new RulesResultsInput(); + body.LatestScan = latestScan; + body.Results = results; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentBaselineRulesOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentBaselineRulesOperationsExtensions.cs new file mode 100644 index 000000000000..0ed1ee0ba393 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentBaselineRulesOperationsExtensions.cs @@ -0,0 +1,304 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SqlVulnerabilityAssessmentBaselineRulesOperations. + /// + public static partial class SqlVulnerabilityAssessmentBaselineRulesOperationsExtensions + { + /// + /// Creates a Baseline for a rule in a database. Will overwrite any previously + /// existing results. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + public static RuleResults CreateOrUpdate(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string ruleId, string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IList> results = default(IList>)) + { + return operations.CreateOrUpdateAsync(ruleId, workspaceId, apiVersion, resourceId, latestScan, results).GetAwaiter().GetResult(); + } + + /// + /// Creates a Baseline for a rule in a database. Will overwrite any previously + /// existing results. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string ruleId, string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IList> results = default(IList>), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(ruleId, workspaceId, apiVersion, resourceId, latestScan, results, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the results for a given rule in the Baseline. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static RuleResults Get(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string ruleId, string workspaceId, string apiVersion, string resourceId) + { + return operations.GetAsync(ruleId, workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets the results for a given rule in the Baseline. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string ruleId, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(ruleId, workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a rule from the Baseline of a given database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static void Delete(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string ruleId, string workspaceId, string apiVersion, string resourceId) + { + operations.DeleteAsync(ruleId, workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Deletes a rule from the Baseline of a given database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The rule Id. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string ruleId, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(ruleId, workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the results for all rules in the Baseline. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static RulesResults List(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string workspaceId, string apiVersion, string resourceId) + { + return operations.ListAsync(workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets the results for all rules in the Baseline. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Add a list of baseline rules. Will overwrite any previously existing + /// results (for all rules). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + public static RulesResults Add(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IDictionary>> results = default(IDictionary>>)) + { + return operations.AddAsync(workspaceId, apiVersion, resourceId, latestScan, results).GetAwaiter().GetResult(); + } + + /// + /// Add a list of baseline rules. Will overwrite any previously existing + /// results (for all rules). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Take results from latest scan. + /// + /// + /// Expected results to be inserted into the baseline. + /// Leave this field empty it LatestScan == true. + /// + /// + /// The cancellation token. + /// + public static async Task AddAsync(this ISqlVulnerabilityAssessmentBaselineRulesOperations operations, string workspaceId, string apiVersion, string resourceId, bool? latestScan = default(bool?), IDictionary>> results = default(IDictionary>>), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AddWithHttpMessagesAsync(workspaceId, apiVersion, resourceId, latestScan, results, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScanResultsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScanResultsOperations.cs new file mode 100644 index 000000000000..5a9f5d770742 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScanResultsOperations.cs @@ -0,0 +1,477 @@ +// +// 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.Security +{ + 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; + + /// + /// SqlVulnerabilityAssessmentScanResultsOperations operations. + /// + internal partial class SqlVulnerabilityAssessmentScanResultsOperations : IServiceOperations, ISqlVulnerabilityAssessmentScanResultsOperations + { + /// + /// Initializes a new instance of the SqlVulnerabilityAssessmentScanResultsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SqlVulnerabilityAssessmentScanResultsOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Gets the scan results of a single rule in a scan record. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest scan. + /// + /// + /// The rule Id of the results. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 scanId, string scanResultId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scanId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scanId"); + } + if (scanResultId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scanResultId"); + } + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scanId", scanId); + tracingParameters.Add("scanResultId", scanResultId); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}").ToString(); + _url = _url.Replace("{scanId}", System.Uri.EscapeDataString(scanId)); + _url = _url.Replace("{scanResultId}", System.Uri.EscapeDataString(scanResultId)); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of scan results for a single scan record. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string scanId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scanId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scanId"); + } + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scanId", scanId); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults").ToString(); + _url = _url.Replace("{scanId}", System.Uri.EscapeDataString(scanId)); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScanResultsOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScanResultsOperationsExtensions.cs new file mode 100644 index 000000000000..d8afab1ab968 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScanResultsOperationsExtensions.cs @@ -0,0 +1,135 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SqlVulnerabilityAssessmentScanResultsOperations. + /// + public static partial class SqlVulnerabilityAssessmentScanResultsOperationsExtensions + { + /// + /// Gets the scan results of a single rule in a scan record. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest scan. + /// + /// + /// The rule Id of the results. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static ScanResult Get(this ISqlVulnerabilityAssessmentScanResultsOperations operations, string scanId, string scanResultId, string workspaceId, string apiVersion, string resourceId) + { + return operations.GetAsync(scanId, scanResultId, workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets the scan results of a single rule in a scan record. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest scan. + /// + /// + /// The rule Id of the results. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISqlVulnerabilityAssessmentScanResultsOperations operations, string scanId, string scanResultId, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scanId, scanResultId, workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of scan results for a single scan record. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static ScanResults List(this ISqlVulnerabilityAssessmentScanResultsOperations operations, string scanId, string workspaceId, string apiVersion, string resourceId) + { + return operations.ListAsync(scanId, workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of scan results for a single scan record. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scan Id. Type 'latest' to get the scan results for the latest scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this ISqlVulnerabilityAssessmentScanResultsOperations operations, string scanId, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(scanId, workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScansOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScansOperations.cs new file mode 100644 index 000000000000..f7fa62fe09b8 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScansOperations.cs @@ -0,0 +1,459 @@ +// +// 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.Security +{ + 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; + + /// + /// SqlVulnerabilityAssessmentScansOperations operations. + /// + internal partial class SqlVulnerabilityAssessmentScansOperations : IServiceOperations, ISqlVulnerabilityAssessmentScansOperations + { + /// + /// Initializes a new instance of the SqlVulnerabilityAssessmentScansOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SqlVulnerabilityAssessmentScansOperations(SecurityCenterClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SecurityCenterClient + /// + public SecurityCenterClient Client { get; private set; } + + /// + /// Gets the scan details of a single scan record. + /// + /// + /// The scan Id. Type 'latest' to get the scan record for the latest scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// 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 scanId, string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scanId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scanId"); + } + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scanId", scanId); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}").ToString(); + _url = _url.Replace("{scanId}", System.Uri.EscapeDataString(scanId)); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of scan records. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string workspaceId, string apiVersion, string resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (workspaceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "workspaceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("workspaceId", workspaceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceId", resourceId); + 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("/") ? "" : "/")), "{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (workspaceId != null) + { + _queryParameters.Add(string.Format("workspaceId={0}", System.Uri.EscapeDataString(workspaceId))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScansOperationsExtensions.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScansOperationsExtensions.cs new file mode 100644 index 000000000000..43f7145dc144 --- /dev/null +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SqlVulnerabilityAssessmentScansOperationsExtensions.cs @@ -0,0 +1,123 @@ +// +// 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.Security +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SqlVulnerabilityAssessmentScansOperations. + /// + public static partial class SqlVulnerabilityAssessmentScansOperationsExtensions + { + /// + /// Gets the scan details of a single scan record. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scan Id. Type 'latest' to get the scan record for the latest scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static Scan Get(this ISqlVulnerabilityAssessmentScansOperations operations, string scanId, string workspaceId, string apiVersion, string resourceId) + { + return operations.GetAsync(scanId, workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets the scan details of a single scan record. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scan Id. Type 'latest' to get the scan record for the latest scan. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISqlVulnerabilityAssessmentScansOperations operations, string scanId, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scanId, workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of scan records. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + public static Scans List(this ISqlVulnerabilityAssessmentScansOperations operations, string workspaceId, string apiVersion, string resourceId) + { + return operations.ListAsync(workspaceId, apiVersion, resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of scan records. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The workspace Id. + /// + /// + /// The api version. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this ISqlVulnerabilityAssessmentScansOperations operations, string workspaceId, string apiVersion, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(workspaceId, apiVersion, resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SubAssessmentsOperations.cs b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SubAssessmentsOperations.cs index a9be02c8a829..e5b502213ff3 100644 --- a/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SubAssessmentsOperations.cs +++ b/sdk/securitycenter/Microsoft.Azure.Management.SecurityCenter/src/Generated/SubAssessmentsOperations.cs @@ -102,7 +102,7 @@ internal SubAssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/subAssessments").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); List _queryParameters = new List(); if (apiVersion != null) { @@ -292,7 +292,7 @@ internal SubAssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); _url = _url.Replace("{assessmentName}", System.Uri.EscapeDataString(assessmentName)); List _queryParameters = new List(); if (apiVersion != null) @@ -491,7 +491,7 @@ internal SubAssessmentsOperations(SecurityCenterClient client) // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}").ToString(); - _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{scope}", scope); _url = _url.Replace("{assessmentName}", System.Uri.EscapeDataString(assessmentName)); _url = _url.Replace("{subAssessmentName}", System.Uri.EscapeDataString(subAssessmentName)); List _queryParameters = new List();