From f9b170f7556bba155d5055b271a88c6d243aceae Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Sun, 24 Mar 2019 19:26:21 +0000 Subject: [PATCH 1/2] .NET SDK Resource Provider:'SecurityCenter' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/4968' REST Spec PR Author 'galmicrosoft' REST Spec PR Last commit --- .../Generated/Models/Alert.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/Alert.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/Alert.cs index c35ea493d428..638034608852 100644 --- a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/Alert.cs +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/Alert.cs @@ -79,9 +79,7 @@ public Alert() /// 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)) + 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)) : base(id, name, type) { State = state; @@ -106,7 +104,6 @@ public Alert() SubscriptionId = subscriptionId; InstanceId = instanceId; WorkspaceArmId = workspaceArmId; - CorrelationKey = correlationKey; CustomInit(); } @@ -254,13 +251,6 @@ public Alert() [JsonProperty(PropertyName = "properties.workspaceArmId")] public string WorkspaceArmId { get; private set; } - /// - /// Gets alerts with the same CorrelationKey will be grouped together - /// in Ibiza. - /// - [JsonProperty(PropertyName = "properties.correlationKey")] - public string CorrelationKey { get; private set; } - /// /// Validate the object. /// From 02e1e762fd77a9a41cf6e9baa5d556cbda424f7c Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Sun, 24 Mar 2019 19:34:39 +0000 Subject: [PATCH 2/2] .NET SDK Resource Provider:'SecurityCenter' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/4968' REST Spec PR Author 'galmicrosoft' REST Spec PR Last commit --- .../DeviceSecurityGroupsOperations.cs | 989 ++++++++++++++++++ ...eviceSecurityGroupsOperationsExtensions.cs | 224 ++++ .../IDeviceSecurityGroupsOperations.cs | 152 +++ .../Generated/ISecurityCenterClient.cs | 5 + .../Models/AllowlistCustomAlertRule.cs | 81 ++ .../Generated/Models/CustomAlertRule.cs | 92 ++ .../Models/DenylistCustomAlertRule.cs | 81 ++ .../Generated/Models/DeviceSecurityGroup.cs | 88 ++ .../Generated/Models/ListCustomAlertRule.cs | 71 ++ .../Models/ThresholdCustomAlertRule.cs | 78 ++ .../Models/TimeWindowCustomAlertRule.cs | 118 +++ .../Generated/Models/ValueType.cs | 28 + .../Generated/SdkInfo_SecurityCenter.cs | 1 + .../Generated/SecurityCenterClient.cs | 6 + 14 files changed, 2014 insertions(+) create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperations.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperationsExtensions.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/IDeviceSecurityGroupsOperations.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/AllowlistCustomAlertRule.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/CustomAlertRule.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DenylistCustomAlertRule.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DeviceSecurityGroup.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ListCustomAlertRule.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ThresholdCustomAlertRule.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/TimeWindowCustomAlertRule.cs create mode 100644 src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ValueType.cs diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperations.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperations.cs new file mode 100644 index 000000000000..4316cf7ec9ff --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperations.cs @@ -0,0 +1,989 @@ +// +// 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; + + /// + /// DeviceSecurityGroupsOperations operations. + /// + internal partial class DeviceSecurityGroupsOperations : IServiceOperations, IDeviceSecurityGroupsOperations + { + /// + /// Initializes a new instance of the DeviceSecurityGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DeviceSecurityGroupsOperations(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 list of device security groups for the specified IoT hub resource. + /// + /// + /// 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 resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + string apiVersion = "2017-08-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("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/deviceSecurityGroups").ToString(); + _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + 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 the device security group for the specified IoT hub resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that 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 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 deviceSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (deviceSecurityGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deviceSecurityGroupName"); + } + string apiVersion = "2017-08-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("resourceId", resourceId); + tracingParameters.Add("deviceSecurityGroupName", deviceSecurityGroupName); + 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/deviceSecurityGroups/{deviceSecurityGroupName}").ToString(); + _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{deviceSecurityGroupName}", System.Uri.EscapeDataString(deviceSecurityGroupName)); + 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; + } + + /// + /// Creates or updates the device security group on a specified IoT hub + /// resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + /// + /// Security group 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> CreateOrUpdateWithHttpMessagesAsync(string resourceId, string deviceSecurityGroupName, DeviceSecurityGroup deviceSecurityGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (deviceSecurityGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deviceSecurityGroupName"); + } + if (deviceSecurityGroup == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deviceSecurityGroup"); + } + string apiVersion = "2017-08-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("resourceId", resourceId); + tracingParameters.Add("deviceSecurityGroupName", deviceSecurityGroupName); + tracingParameters.Add("deviceSecurityGroup", deviceSecurityGroup); + 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/deviceSecurityGroups/{deviceSecurityGroupName}").ToString(); + _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{deviceSecurityGroupName}", System.Uri.EscapeDataString(deviceSecurityGroupName)); + 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(deviceSecurityGroup != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(deviceSecurityGroup, 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; + } + + /// + /// Deletes the security group + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that 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 DeleteWithHttpMessagesAsync(string resourceId, string deviceSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (deviceSecurityGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deviceSecurityGroupName"); + } + string apiVersion = "2017-08-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("resourceId", resourceId); + tracingParameters.Add("deviceSecurityGroupName", deviceSecurityGroupName); + 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/deviceSecurityGroups/{deviceSecurityGroupName}").ToString(); + _url = _url.Replace("{resourceId}", System.Uri.EscapeDataString(resourceId)); + _url = _url.Replace("{deviceSecurityGroupName}", System.Uri.EscapeDataString(deviceSecurityGroupName)); + 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; + } + + /// + /// Gets the list of device security groups 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/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperationsExtensions.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperationsExtensions.cs new file mode 100644 index 000000000000..5edc87bd69b7 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/DeviceSecurityGroupsOperationsExtensions.cs @@ -0,0 +1,224 @@ +// +// 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 DeviceSecurityGroupsOperations. + /// + public static partial class DeviceSecurityGroupsOperationsExtensions + { + /// + /// Gets the list of device security groups for the specified IoT hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + public static IPage List(this IDeviceSecurityGroupsOperations operations, string resourceId) + { + return operations.ListAsync(resourceId).GetAwaiter().GetResult(); + } + + /// + /// Gets the list of device security groups for the specified IoT hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDeviceSecurityGroupsOperations operations, string resourceId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the device security group for the specified IoT hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + public static DeviceSecurityGroup Get(this IDeviceSecurityGroupsOperations operations, string resourceId, string deviceSecurityGroupName) + { + return operations.GetAsync(resourceId, deviceSecurityGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets the device security group for the specified IoT hub resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDeviceSecurityGroupsOperations operations, string resourceId, string deviceSecurityGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceId, deviceSecurityGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates the device security group on a specified IoT hub + /// resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + /// + /// Security group object. + /// + public static DeviceSecurityGroup CreateOrUpdate(this IDeviceSecurityGroupsOperations operations, string resourceId, string deviceSecurityGroupName, DeviceSecurityGroup deviceSecurityGroup) + { + return operations.CreateOrUpdateAsync(resourceId, deviceSecurityGroupName, deviceSecurityGroup).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates the device security group on a specified IoT hub + /// resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + /// + /// Security group object. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDeviceSecurityGroupsOperations operations, string resourceId, string deviceSecurityGroupName, DeviceSecurityGroup deviceSecurityGroup, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceId, deviceSecurityGroupName, deviceSecurityGroup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the security group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + public static void Delete(this IDeviceSecurityGroupsOperations operations, string resourceId, string deviceSecurityGroupName) + { + operations.DeleteAsync(resourceId, deviceSecurityGroupName).GetAwaiter().GetResult(); + } + + /// + /// Deletes the security group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDeviceSecurityGroupsOperations operations, string resourceId, string deviceSecurityGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceId, deviceSecurityGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the list of device security groups 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 IDeviceSecurityGroupsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets the list of device security groups 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 IDeviceSecurityGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/IDeviceSecurityGroupsOperations.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/IDeviceSecurityGroupsOperations.cs new file mode 100644 index 000000000000..9051b1d7a484 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/IDeviceSecurityGroupsOperations.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.Threading; + using System.Threading.Tasks; + + /// + /// DeviceSecurityGroupsOperations operations. + /// + public partial interface IDeviceSecurityGroupsOperations + { + /// + /// Gets the list of device security groups for the specified IoT hub + /// resource. + /// + /// + /// 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 resourceId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the device security group for the specified IoT hub resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that 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 unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceId, string deviceSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates the device security group on a specified IoT hub + /// resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that the name is case + /// insensitive. + /// + /// + /// Security group 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> CreateOrUpdateWithHttpMessagesAsync(string resourceId, string deviceSecurityGroupName, DeviceSecurityGroup deviceSecurityGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the security group + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the security group. Please notice that 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 DeleteWithHttpMessagesAsync(string resourceId, string deviceSecurityGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the list of device security groups 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/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/ISecurityCenterClient.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/ISecurityCenterClient.cs index ade7a7709bab..07961be73714 100644 --- a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/ISecurityCenterClient.cs +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/ISecurityCenterClient.cs @@ -101,6 +101,11 @@ public partial interface ISecurityCenterClient : System.IDisposable /// IAdvancedThreatProtectionOperations AdvancedThreatProtection { get; } + /// + /// Gets the IDeviceSecurityGroupsOperations. + /// + IDeviceSecurityGroupsOperations DeviceSecurityGroups { get; } + /// /// Gets the ISettingsOperations. /// diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/AllowlistCustomAlertRule.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/AllowlistCustomAlertRule.cs new file mode 100644 index 000000000000..6b949c81f206 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/AllowlistCustomAlertRule.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 Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A custom alert rule that checks if a value (depends on the custom alert + /// type) is allowed + /// + public partial class AllowlistCustomAlertRule : ListCustomAlertRule + { + /// + /// Initializes a new instance of the AllowlistCustomAlertRule class. + /// + public AllowlistCustomAlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AllowlistCustomAlertRule class. + /// + /// Whether the custom alert is + /// enabled. + /// The type of the custom alert rule. + /// The values to allow. The format of + /// the values depends on the rule type. + /// The display name of the custom + /// alert. + /// The description of the custom + /// alert. + /// The value type of the items in the list. + /// Possible values include: 'IpCidr', 'String' + public AllowlistCustomAlertRule(bool isEnabled, string ruleType, IList allowlistValues, string displayName = default(string), string description = default(string), string valueType = default(string)) + : base(isEnabled, ruleType, displayName, description, valueType) + { + AllowlistValues = allowlistValues; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the values to allow. The format of the values depends + /// on the rule type. + /// + [JsonProperty(PropertyName = "allowlistValues")] + public IList AllowlistValues { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (AllowlistValues == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AllowlistValues"); + } + } + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/CustomAlertRule.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/CustomAlertRule.cs new file mode 100644 index 000000000000..8b55463978f4 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/CustomAlertRule.cs @@ -0,0 +1,92 @@ +// +// 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; + + /// + /// A custom alert rule + /// + public partial class CustomAlertRule + { + /// + /// Initializes a new instance of the CustomAlertRule class. + /// + public CustomAlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomAlertRule class. + /// + /// Whether the custom alert is + /// enabled. + /// The type of the custom alert rule. + /// The display name of the custom + /// alert. + /// The description of the custom + /// alert. + public CustomAlertRule(bool isEnabled, string ruleType, string displayName = default(string), string description = default(string)) + { + DisplayName = displayName; + Description = description; + IsEnabled = isEnabled; + RuleType = ruleType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the display name of the custom alert. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the description of the custom alert. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + /// + /// Gets or sets whether the custom alert is enabled. + /// + [JsonProperty(PropertyName = "isEnabled")] + public bool IsEnabled { get; set; } + + /// + /// Gets or sets the type of the custom alert rule. + /// + [JsonProperty(PropertyName = "ruleType")] + public string RuleType { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RuleType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RuleType"); + } + } + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DenylistCustomAlertRule.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DenylistCustomAlertRule.cs new file mode 100644 index 000000000000..d9180244dbd2 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DenylistCustomAlertRule.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 Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A custom alert rule that checks if a value (depends on the custom alert + /// type) is denied + /// + public partial class DenylistCustomAlertRule : ListCustomAlertRule + { + /// + /// Initializes a new instance of the DenylistCustomAlertRule class. + /// + public DenylistCustomAlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DenylistCustomAlertRule class. + /// + /// Whether the custom alert is + /// enabled. + /// The type of the custom alert rule. + /// The values to deny. The format of the + /// values depends on the rule type. + /// The display name of the custom + /// alert. + /// The description of the custom + /// alert. + /// The value type of the items in the list. + /// Possible values include: 'IpCidr', 'String' + public DenylistCustomAlertRule(bool isEnabled, string ruleType, IList denylistValues, string displayName = default(string), string description = default(string), string valueType = default(string)) + : base(isEnabled, ruleType, displayName, description, valueType) + { + DenylistValues = denylistValues; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the values to deny. The format of the values depends + /// on the rule type. + /// + [JsonProperty(PropertyName = "denylistValues")] + public IList DenylistValues { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (DenylistValues == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DenylistValues"); + } + } + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DeviceSecurityGroup.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DeviceSecurityGroup.cs new file mode 100644 index 000000000000..549cc08d1a17 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/DeviceSecurityGroup.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Security.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The device security group resource + /// + [Rest.Serialization.JsonTransformation] + public partial class DeviceSecurityGroup : Resource + { + /// + /// Initializes a new instance of the DeviceSecurityGroup class. + /// + public DeviceSecurityGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeviceSecurityGroup class. + /// + /// Resource Id + /// Resource name + /// Resource type + /// A list of threshold custom alert + /// rules. + /// A list of time window custom alert + /// rules. + /// A list of allow-list custom alert + /// rules. + /// A list of deny-list custom alert + /// rules. + public DeviceSecurityGroup(string id = default(string), string name = default(string), string type = default(string), IList thresholdRules = default(IList), IList timeWindowRules = default(IList), IList allowlistRules = default(IList), IList denylistRules = default(IList)) + : base(id, name, type) + { + ThresholdRules = thresholdRules; + TimeWindowRules = timeWindowRules; + AllowlistRules = allowlistRules; + DenylistRules = denylistRules; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a list of threshold custom alert rules. + /// + [JsonProperty(PropertyName = "properties.thresholdRules")] + public IList ThresholdRules { get; set; } + + /// + /// Gets or sets a list of time window custom alert rules. + /// + [JsonProperty(PropertyName = "properties.timeWindowRules")] + public IList TimeWindowRules { get; set; } + + /// + /// Gets or sets a list of allow-list custom alert rules. + /// + [JsonProperty(PropertyName = "properties.allowlistRules")] + public IList AllowlistRules { get; set; } + + /// + /// Gets or sets a list of deny-list custom alert rules. + /// + [JsonProperty(PropertyName = "properties.denylistRules")] + public IList DenylistRules { get; set; } + + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ListCustomAlertRule.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ListCustomAlertRule.cs new file mode 100644 index 000000000000..93cbb9651374 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ListCustomAlertRule.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.Linq; + + /// + /// A List custom alert rule + /// + public partial class ListCustomAlertRule : CustomAlertRule + { + /// + /// Initializes a new instance of the ListCustomAlertRule class. + /// + public ListCustomAlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ListCustomAlertRule class. + /// + /// Whether the custom alert is + /// enabled. + /// The type of the custom alert rule. + /// The display name of the custom + /// alert. + /// The description of the custom + /// alert. + /// The value type of the items in the list. + /// Possible values include: 'IpCidr', 'String' + public ListCustomAlertRule(bool isEnabled, string ruleType, string displayName = default(string), string description = default(string), string valueType = default(string)) + : base(isEnabled, ruleType, displayName, description) + { + ValueType = valueType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the value type of the items in the list. Possible values + /// include: 'IpCidr', 'String' + /// + [JsonProperty(PropertyName = "valueType")] + public string ValueType { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ThresholdCustomAlertRule.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ThresholdCustomAlertRule.cs new file mode 100644 index 000000000000..2e56a991e969 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ThresholdCustomAlertRule.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.Linq; + + /// + /// A custom alert rule that checks if a value (depends on the custom alert + /// type) is within the given range. + /// + public partial class ThresholdCustomAlertRule : CustomAlertRule + { + /// + /// Initializes a new instance of the ThresholdCustomAlertRule class. + /// + public ThresholdCustomAlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ThresholdCustomAlertRule class. + /// + /// Whether the custom alert is + /// enabled. + /// The type of the custom alert rule. + /// The minimum threshold. + /// The maximum threshold. + /// The display name of the custom + /// alert. + /// The description of the custom + /// alert. + public ThresholdCustomAlertRule(bool isEnabled, string ruleType, int minThreshold, int maxThreshold, string displayName = default(string), string description = default(string)) + : base(isEnabled, ruleType, displayName, description) + { + MinThreshold = minThreshold; + MaxThreshold = maxThreshold; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the minimum threshold. + /// + [JsonProperty(PropertyName = "minThreshold")] + public int MinThreshold { get; set; } + + /// + /// Gets or sets the maximum threshold. + /// + [JsonProperty(PropertyName = "maxThreshold")] + public int MaxThreshold { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/TimeWindowCustomAlertRule.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/TimeWindowCustomAlertRule.cs new file mode 100644 index 000000000000..c9097faff8ab --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/TimeWindowCustomAlertRule.cs @@ -0,0 +1,118 @@ +// +// 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; + + /// + /// 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. + /// + public partial class TimeWindowCustomAlertRule + { + /// + /// Initializes a new instance of the TimeWindowCustomAlertRule class. + /// + public TimeWindowCustomAlertRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TimeWindowCustomAlertRule class. + /// + /// Whether the custom alert is + /// enabled. + /// The type of the custom alert rule. + /// The minimum threshold. + /// The maximum threshold. + /// The time window size in iso8601 + /// format. + /// The display name of the custom + /// alert. + /// The description of the custom + /// alert. + public TimeWindowCustomAlertRule(bool isEnabled, string ruleType, int minThreshold, int maxThreshold, System.TimeSpan timeWindowSize, string displayName = default(string), string description = default(string)) + { + DisplayName = displayName; + Description = description; + IsEnabled = isEnabled; + RuleType = ruleType; + MinThreshold = minThreshold; + MaxThreshold = maxThreshold; + TimeWindowSize = timeWindowSize; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the display name of the custom alert. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the description of the custom alert. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + /// + /// Gets or sets whether the custom alert is enabled. + /// + [JsonProperty(PropertyName = "isEnabled")] + public bool IsEnabled { get; set; } + + /// + /// Gets or sets the type of the custom alert rule. + /// + [JsonProperty(PropertyName = "ruleType")] + public string RuleType { get; set; } + + /// + /// Gets or sets the minimum threshold. + /// + [JsonProperty(PropertyName = "minThreshold")] + public int MinThreshold { get; set; } + + /// + /// Gets or sets the maximum threshold. + /// + [JsonProperty(PropertyName = "maxThreshold")] + public int MaxThreshold { get; set; } + + /// + /// Gets or sets the time window size in iso8601 format. + /// + [JsonProperty(PropertyName = "timeWindowSize")] + public System.TimeSpan TimeWindowSize { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RuleType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RuleType"); + } + } + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ValueType.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ValueType.cs new file mode 100644 index 000000000000..555342f47de3 --- /dev/null +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/Models/ValueType.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 ValueType. + /// + public static class ValueType + { + /// + /// An IP range in CIDR format (e.g. '192.168.0.1/8'). + /// + public const string IpCidr = "IpCidr"; + /// + /// Any string value. + /// + public const string String = "String"; + } +} diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SdkInfo_SecurityCenter.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SdkInfo_SecurityCenter.cs index 9e6606539d89..3e923cd3030b 100644 --- a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SdkInfo_SecurityCenter.cs +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SdkInfo_SecurityCenter.cs @@ -24,6 +24,7 @@ public static IEnumerable> ApiInfo_SecurityCenter new Tuple("Security", "AllowedConnections", "2015-06-01-preview"), new Tuple("Security", "AutoProvisioningSettings", "2017-08-01-preview"), new Tuple("Security", "Compliances", "2017-08-01-preview"), + new Tuple("Security", "DeviceSecurityGroups", "2017-08-01-preview"), new Tuple("Security", "DiscoveredSecuritySolutions", "2015-06-01-preview"), new Tuple("Security", "ExternalSecuritySolutions", "2015-06-01-preview"), new Tuple("Security", "InformationProtectionPolicies", "2017-08-01-preview"), diff --git a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SecurityCenterClient.cs b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SecurityCenterClient.cs index b0d97114b093..db6e9c77f525 100644 --- a/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SecurityCenterClient.cs +++ b/src/SDKs/SecurityCenter/Management.SecurityCenter/Generated/SecurityCenterClient.cs @@ -106,6 +106,11 @@ public partial class SecurityCenterClient : ServiceClient, /// public virtual IAdvancedThreatProtectionOperations AdvancedThreatProtection { get; private set; } + /// + /// Gets the IDeviceSecurityGroupsOperations. + /// + public virtual IDeviceSecurityGroupsOperations DeviceSecurityGroups { get; private set; } + /// /// Gets the ISettingsOperations. /// @@ -408,6 +413,7 @@ private void Initialize() AutoProvisioningSettings = new AutoProvisioningSettingsOperations(this); Compliances = new CompliancesOperations(this); AdvancedThreatProtection = new AdvancedThreatProtectionOperations(this); + DeviceSecurityGroups = new DeviceSecurityGroupsOperations(this); Settings = new SettingsOperations(this); InformationProtectionPolicies = new InformationProtectionPoliciesOperations(this); Operations = new Operations(this);