From c6f6da5baa0061bff3e1434faeb373463d8a28fd Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Wed, 5 Feb 2020 20:51:56 +0000 Subject: [PATCH] Generated from b7bd004a2d2e22c35bdaaa9379fe5c4aa3de7352 made prettier --- .../src/Generated/IPolicyStatesOperations.cs | 86 +++++ .../src/Generated/PolicyStatesOperations.cs | 362 ++++++++++++++++++ .../PolicyStatesOperationsExtensions.cs | 144 +++++++ .../Generated/SdkInfo_PolicyInsightsClient.cs | 11 - 4 files changed, 592 insertions(+), 11 deletions(-) diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs index 5d9cb796ce4ae..3c1afc8af939a 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs @@ -256,6 +256,49 @@ public partial interface IPolicyStatesOperations /// Task> SummarizeForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// 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 TriggerSubscriptionEvaluationWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Triggers a policy evaluation scan for all the resources under the + /// resource group. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + /// + /// 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 TriggerResourceGroupEvaluationWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Queries policy states for the subscription level policy set /// definition. /// @@ -515,5 +558,48 @@ public partial interface IPolicyStatesOperations /// Thrown when a required parameter is null /// Task> SummarizeForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// 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 BeginTriggerSubscriptionEvaluationWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Triggers a policy evaluation scan for all the resources under the + /// resource group. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + /// + /// 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 BeginTriggerResourceGroupEvaluationWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs index 6c6e84f47eb49..81ef8ae38860b 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs @@ -2008,6 +2008,49 @@ internal PolicyStatesOperations(PolicyInsightsClient client) return _result; } + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task TriggerSubscriptionEvaluationWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginTriggerSubscriptionEvaluationWithHttpMessagesAsync(subscriptionId, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the resource + /// group. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task TriggerResourceGroupEvaluationWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginTriggerResourceGroupEvaluationWithHttpMessagesAsync(subscriptionId, resourceGroupName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + /// /// Queries policy states for the subscription level policy set definition. /// @@ -4046,5 +4089,324 @@ internal PolicyStatesOperations(PolicyInsightsClient client) return _result; } + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// 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 BeginTriggerSubscriptionEvaluationWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + string apiVersion = "2019-10-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginTriggerSubscriptionEvaluation", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(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 && (int)_statusCode != 202) + { + var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Triggers a policy evaluation scan for all the resources under the resource + /// group. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + /// + /// 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 BeginTriggerResourceGroupEvaluationWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + string apiVersion = "2019-10-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginTriggerResourceGroupEvaluation", 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.PolicyInsights/policyStates/latest/triggerEvaluation").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_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 && (int)_statusCode != 202) + { + var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs index f07e2a859e83f..97d3527cde72e 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs @@ -401,6 +401,78 @@ public static partial class PolicyStatesOperationsExtensions } } + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + public static void TriggerSubscriptionEvaluation(this IPolicyStatesOperations operations, string subscriptionId) + { + operations.TriggerSubscriptionEvaluationAsync(subscriptionId).GetAwaiter().GetResult(); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// The cancellation token. + /// + public static async Task TriggerSubscriptionEvaluationAsync(this IPolicyStatesOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.TriggerSubscriptionEvaluationWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + public static void TriggerResourceGroupEvaluation(this IPolicyStatesOperations operations, string subscriptionId, string resourceGroupName) + { + operations.TriggerResourceGroupEvaluationAsync(subscriptionId, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task TriggerResourceGroupEvaluationAsync(this IPolicyStatesOperations operations, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.TriggerResourceGroupEvaluationWithHttpMessagesAsync(subscriptionId, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// /// Queries policy states for the subscription level policy set definition. /// @@ -829,5 +901,77 @@ public static partial class PolicyStatesOperationsExtensions } } + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + public static void BeginTriggerSubscriptionEvaluation(this IPolicyStatesOperations operations, string subscriptionId) + { + operations.BeginTriggerSubscriptionEvaluationAsync(subscriptionId).GetAwaiter().GetResult(); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the + /// subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// The cancellation token. + /// + public static async Task BeginTriggerSubscriptionEvaluationAsync(this IPolicyStatesOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginTriggerSubscriptionEvaluationWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + public static void BeginTriggerResourceGroupEvaluation(this IPolicyStatesOperations operations, string subscriptionId, string resourceGroupName) + { + operations.BeginTriggerResourceGroupEvaluationAsync(subscriptionId, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Triggers a policy evaluation scan for all the resources under the resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Microsoft Azure subscription ID. + /// + /// + /// Resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginTriggerResourceGroupEvaluationAsync(this IPolicyStatesOperations operations, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginTriggerResourceGroupEvaluationWithHttpMessagesAsync(subscriptionId, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs index 3718077dd5b02..8809137e37b18 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs @@ -28,16 +28,5 @@ public static IEnumerable> ApiInfo_PolicyInsightsC }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "latest"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4407"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/policyinsights/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\\work\\apiReview\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "df4187f875393a39197055e879ddd0c2ae63e84c"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } -