From cae023c4b075867717c24ae71b3e214e5e86848c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 1 Sep 2021 22:20:50 +0000 Subject: [PATCH] CodeGen from PR 15888 in Azure/azure-rest-api-specs Merge 143d3eb6e59bcd890bb58b13220fb1cfda0c99d9 into 1df5cd4d0562f14d112edc77e72843d0d5132136 --- .../src/Generated/AttestationsOperations.cs | 3067 +++++++++++++++++ .../AttestationsOperationsExtensions.cs | 784 +++++ .../src/Generated/IAttestationsOperations.cs | 492 +++ .../src/Generated/IPolicyEventsOperations.cs | 16 +- .../src/Generated/IPolicyInsightsClient.cs | 15 + .../IPolicyRestrictionsOperations.cs | 83 + .../src/Generated/IPolicyStatesOperations.cs | 16 +- .../src/Generated/Models/Attestation.cs | 177 + .../Generated/Models/AttestationEvidence.cs | 61 + .../Generated/Models/AzureEntityResource.cs | 62 + .../Models/CheckRestrictionsRequest.cs | 94 + .../CheckRestrictionsResourceDetails.cs | 92 + .../Models/CheckRestrictionsResult.cs | 64 + ...strictionsResultContentEvaluationResult.cs | 59 + .../src/Generated/Models/ComplianceState.cs | 32 + .../src/Generated/Models/CreatedByType.cs | 24 + .../Models/ExpressionEvaluationDetails.cs | 11 +- .../src/Generated/Models/FieldRestriction.cs | 86 + .../Models/FieldRestrictionResult.cs | 32 + .../src/Generated/Models/FieldRestrictions.cs | 66 + .../src/Generated/Models/PendingField.cs | 81 + .../Models/PolicyEvaluationResult.cs | 75 + .../src/Generated/Models/PolicyReference.cs | 81 + .../src/Generated/Models/ProxyResource.cs | 53 + .../src/Generated/Models/Resource.cs | 79 + .../src/Generated/Models/SystemData.cs | 103 + .../src/Generated/Models/TrackedResource.cs | 87 + .../src/Generated/PolicyEventsOperations.cs | 32 +- .../PolicyEventsOperationsExtensions.cs | 64 +- .../src/Generated/PolicyInsightsClient.cs | 17 + .../Generated/PolicyRestrictionsOperations.cs | 477 +++ .../PolicyRestrictionsOperationsExtensions.cs | 117 + .../src/Generated/PolicyStatesOperations.cs | 32 +- .../PolicyStatesOperationsExtensions.cs | 64 +- .../Generated/SdkInfo_PolicyInsightsClient.cs | 13 +- 35 files changed, 6584 insertions(+), 124 deletions(-) create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperations.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperationsExtensions.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IAttestationsOperations.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyRestrictionsOperations.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Attestation.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AttestationEvidence.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AzureEntityResource.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsRequest.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResourceDetails.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResult.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResultContentEvaluationResult.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ComplianceState.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CreatedByType.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestriction.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictionResult.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictions.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PendingField.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEvaluationResult.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyReference.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ProxyResource.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Resource.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/SystemData.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/TrackedResource.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperations.cs create mode 100644 sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperationsExtensions.cs diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperations.cs new file mode 100644 index 0000000000000..5dc143e8e76d3 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperations.cs @@ -0,0 +1,3067 @@ +// +// 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.PolicyInsights +{ + 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; + + /// + /// AttestationsOperations operations. + /// + internal partial class AttestationsOperations : IServiceOperations, IAttestationsOperations + { + /// + /// Initializes a new instance of the AttestationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AttestationsOperations(PolicyInsightsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyInsightsClient + /// + public PolicyInsightsClient Client { get; private set; } + + /// + /// Gets all attestations for the subscription. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Additional parameters for the operation + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + string apiVersion = "2021-01-01"; + int? top = default(int?); + if (queryOptions != null) + { + top = queryOptions.Top; + } + string filter = default(string); + if (queryOptions != null) + { + filter = queryOptions.Filter; + } + // 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("top", top); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations").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 (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtSubscriptionWithHttpMessagesAsync(subscriptionId, attestationName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an existing attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// 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> GetAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + string apiVersion = "2021-01-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("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// 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 DeleteAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + string apiVersion = "2021-01-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("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Gets all attestations for the resource group. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Additional parameters for the operation + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + string apiVersion = "2021-01-01"; + int? top = default(int?); + if (queryOptions != null) + { + top = queryOptions.Top; + } + string filter = default(string); + if (queryOptions != null) + { + filter = queryOptions.Filter; + } + // 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("top", top); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForResourceGroup", 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/attestations").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 (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, attestationName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an existing attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// 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> GetAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + string apiVersion = "2021-01-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("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtResourceGroup", 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/attestations/{attestationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// 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 DeleteAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + string apiVersion = "2021-01-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("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtResourceGroup", 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/attestations/{attestationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Gets all attestations for a resource. + /// + /// + /// Resource ID. + /// + /// + /// Additional parameters for the operation + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + string apiVersion = "2021-01-01"; + int? top = default(int?); + if (queryOptions != null) + { + top = queryOptions.Top; + } + string filter = default(string); + if (queryOptions != null) + { + filter = queryOptions.Filter; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForResource", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/attestations").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtResourceWithHttpMessagesAsync(resourceId, attestationName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an existing attestation at resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// 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> GetAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + string apiVersion = "2021-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtResource", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing attestation at individual resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// 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 DeleteAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + string apiVersion = "2021-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtResource", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> BeginCreateOrUpdateAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2021-01-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("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> BeginCreateOrUpdateAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2021-01-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("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtResourceGroup", 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/attestations/{attestationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> BeginCreateOrUpdateAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (attestationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "attestationName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2021-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("attestationName", attestationName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtResource", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + _url = _url.Replace("{attestationName}", System.Uri.EscapeDataString(attestationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all attestations for the subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListForSubscriptionNextWithHttpMessagesAsync(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, "ListForSubscriptionNext", 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all attestations for the resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListForResourceGroupNextWithHttpMessagesAsync(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, "ListForResourceGroupNext", 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all attestations for a 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>> ListForResourceNextWithHttpMessagesAsync(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, "ListForResourceNext", 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperationsExtensions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperationsExtensions.cs new file mode 100644 index 0000000000000..1a10797b30f1c --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/AttestationsOperationsExtensions.cs @@ -0,0 +1,784 @@ +// +// 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.PolicyInsights +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AttestationsOperations. + /// + public static partial class AttestationsOperationsExtensions + { + /// + /// Gets all attestations for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Additional parameters for the operation + /// + public static IPage ListForSubscription(this IAttestationsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions)) + { + return operations.ListForSubscriptionAsync(subscriptionId, queryOptions).GetAwaiter().GetResult(); + } + + /// + /// Gets all attestations for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task> ListForSubscriptionAsync(this IAttestationsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForSubscriptionWithHttpMessagesAsync(subscriptionId, queryOptions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + public static Attestation CreateOrUpdateAtSubscription(this IAttestationsOperations operations, string subscriptionId, string attestationName, Attestation parameters) + { + return operations.CreateOrUpdateAtSubscriptionAsync(subscriptionId, attestationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtSubscriptionAsync(this IAttestationsOperations operations, string subscriptionId, string attestationName, Attestation parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtSubscriptionWithHttpMessagesAsync(subscriptionId, attestationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + public static Attestation GetAtSubscription(this IAttestationsOperations operations, string subscriptionId, string attestationName) + { + return operations.GetAtSubscriptionAsync(subscriptionId, attestationName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtSubscriptionAsync(this IAttestationsOperations operations, string subscriptionId, string attestationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtSubscriptionWithHttpMessagesAsync(subscriptionId, attestationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + public static void DeleteAtSubscription(this IAttestationsOperations operations, string subscriptionId, string attestationName) + { + operations.DeleteAtSubscriptionAsync(subscriptionId, attestationName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtSubscriptionAsync(this IAttestationsOperations operations, string subscriptionId, string attestationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtSubscriptionWithHttpMessagesAsync(subscriptionId, attestationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets all attestations for the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Additional parameters for the operation + /// + public static IPage ListForResourceGroup(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions)) + { + return operations.ListForResourceGroupAsync(subscriptionId, resourceGroupName, queryOptions).GetAwaiter().GetResult(); + } + + /// + /// Gets all attestations for the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceGroupAsync(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, queryOptions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + public static Attestation CreateOrUpdateAtResourceGroup(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters) + { + return operations.CreateOrUpdateAtResourceGroupAsync(subscriptionId, resourceGroupName, attestationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtResourceGroupAsync(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, attestationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + public static Attestation GetAtResourceGroup(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName) + { + return operations.GetAtResourceGroupAsync(subscriptionId, resourceGroupName, attestationName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtResourceGroupAsync(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, attestationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + public static void DeleteAtResourceGroup(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName) + { + operations.DeleteAtResourceGroupAsync(subscriptionId, resourceGroupName, attestationName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtResourceGroupAsync(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, attestationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets all attestations for a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// Additional parameters for the operation + /// + public static IPage ListForResource(this IAttestationsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions)) + { + return operations.ListForResourceAsync(resourceId, queryOptions).GetAwaiter().GetResult(); + } + + /// + /// Gets all attestations for a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceAsync(this IAttestationsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceWithHttpMessagesAsync(resourceId, queryOptions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + public static Attestation CreateOrUpdateAtResource(this IAttestationsOperations operations, string resourceId, string attestationName, Attestation parameters) + { + return operations.CreateOrUpdateAtResourceAsync(resourceId, attestationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtResourceAsync(this IAttestationsOperations operations, string resourceId, string attestationName, Attestation parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtResourceWithHttpMessagesAsync(resourceId, attestationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing attestation at resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + public static Attestation GetAtResource(this IAttestationsOperations operations, string resourceId, string attestationName) + { + return operations.GetAtResourceAsync(resourceId, attestationName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing attestation at resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtResourceAsync(this IAttestationsOperations operations, string resourceId, string attestationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtResourceWithHttpMessagesAsync(resourceId, attestationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing attestation at individual resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + public static void DeleteAtResource(this IAttestationsOperations operations, string resourceId, string attestationName) + { + operations.DeleteAtResourceAsync(resourceId, attestationName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing attestation at individual resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtResourceAsync(this IAttestationsOperations operations, string resourceId, string attestationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtResourceWithHttpMessagesAsync(resourceId, attestationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + public static Attestation BeginCreateOrUpdateAtSubscription(this IAttestationsOperations operations, string subscriptionId, string attestationName, Attestation parameters) + { + return operations.BeginCreateOrUpdateAtSubscriptionAsync(subscriptionId, attestationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtSubscriptionAsync(this IAttestationsOperations operations, string subscriptionId, string attestationName, Attestation parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtSubscriptionWithHttpMessagesAsync(subscriptionId, attestationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + public static Attestation BeginCreateOrUpdateAtResourceGroup(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters) + { + return operations.BeginCreateOrUpdateAtResourceGroupAsync(subscriptionId, resourceGroupName, attestationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtResourceGroupAsync(this IAttestationsOperations operations, string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, attestationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + public static Attestation BeginCreateOrUpdateAtResource(this IAttestationsOperations operations, string resourceId, string attestationName, Attestation parameters) + { + return operations.BeginCreateOrUpdateAtResourceAsync(resourceId, attestationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtResourceAsync(this IAttestationsOperations operations, string resourceId, string attestationName, Attestation parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtResourceWithHttpMessagesAsync(resourceId, attestationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all attestations for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForSubscriptionNext(this IAttestationsOperations operations, string nextPageLink) + { + return operations.ListForSubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all attestations for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForSubscriptionNextAsync(this IAttestationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForSubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all attestations for the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForResourceGroupNext(this IAttestationsOperations operations, string nextPageLink) + { + return operations.ListForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all attestations for the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceGroupNextAsync(this IAttestationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all attestations for a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForResourceNext(this IAttestationsOperations operations, string nextPageLink) + { + return operations.ListForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all attestations for a 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> ListForResourceNextAsync(this IAttestationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IAttestationsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IAttestationsOperations.cs new file mode 100644 index 0000000000000..d7726b374b45c --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IAttestationsOperations.cs @@ -0,0 +1,492 @@ +// +// 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.PolicyInsights +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AttestationsOperations operations. + /// + public partial interface IAttestationsOperations + { + /// + /// Gets all attestations for the subscription. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> CreateOrUpdateAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// 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> GetAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// 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 DeleteAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all attestations for the resource group. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> CreateOrUpdateAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// 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> GetAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// 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 DeleteAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all attestations for a resource. + /// + /// + /// Resource ID. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> CreateOrUpdateAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing attestation at resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// 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> GetAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing attestation at individual resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// 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 DeleteAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an attestation at subscription scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> BeginCreateOrUpdateAtSubscriptionWithHttpMessagesAsync(string subscriptionId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an attestation at resource group scope. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> BeginCreateOrUpdateAtResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an attestation at resource scope. + /// + /// + /// Resource ID. + /// + /// + /// The name of the attestation. + /// + /// + /// The attestation parameters. + /// + /// + /// 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> BeginCreateOrUpdateAtResourceWithHttpMessagesAsync(string resourceId, string attestationName, Attestation parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all attestations for the subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all attestations for the resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all attestations for a 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>> ListForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs index c87ff101479ae..6c67f0a0ed56b 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs @@ -264,7 +264,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLinkWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the resources under the subscription. /// @@ -286,7 +286,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink1WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the resources under the resource group. /// @@ -308,7 +308,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink2WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the resource. /// @@ -330,7 +330,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink3WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the subscription level policy set /// definition. @@ -353,7 +353,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink4WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the subscription level policy definition. /// @@ -375,7 +375,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink5WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the subscription level policy assignment. /// @@ -397,7 +397,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink6WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the resource group level policy /// assignment. @@ -420,6 +420,6 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink7WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyInsightsClient.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyInsightsClient.cs index 4a5a154b404fd..bbc298705a97d 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyInsightsClient.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyInsightsClient.cs @@ -39,6 +39,11 @@ public partial interface IPolicyInsightsClient : System.IDisposable /// ServiceClientCredentials Credentials { get; } + /// + /// The ID of the target subscription. + /// + string SubscriptionId2 { get; set; } + /// /// The preferred language for the response. /// @@ -88,5 +93,15 @@ public partial interface IPolicyInsightsClient : System.IDisposable /// IPolicyMetadataOperations PolicyMetadata { get; } + /// + /// Gets the IPolicyRestrictionsOperations. + /// + IPolicyRestrictionsOperations PolicyRestrictions { get; } + + /// + /// Gets the IAttestationsOperations. + /// + IAttestationsOperations Attestations { get; } + } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyRestrictionsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyRestrictionsOperations.cs new file mode 100644 index 0000000000000..67a77a6ec6107 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyRestrictionsOperations.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PolicyRestrictionsOperations operations. + /// + public partial interface IPolicyRestrictionsOperations + { + /// + /// Checks what restrictions Azure Policy will place on a resource + /// within a subscription. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The check policy restrictions parameters. + /// + /// + /// 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> CheckAtSubscriptionScopeWithHttpMessagesAsync(string subscriptionId, CheckRestrictionsRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks what restrictions Azure Policy will place on a resource + /// within a resource group. Use this when the resource group the + /// resource will be created in is already known. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The check policy restrictions parameters. + /// + /// + /// 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> CheckAtResourceGroupScopeWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, CheckRestrictionsRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} 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 823d7d7d6c448..9c1ec1f83a910 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs @@ -622,7 +622,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLinkWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the resources under the subscription. /// @@ -644,7 +644,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink1WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the resources under the resource group. /// @@ -666,7 +666,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink2WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the resource. /// @@ -688,7 +688,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink3WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the subscription level policy set /// definition. @@ -711,7 +711,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink4WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the subscription level policy definition. /// @@ -733,7 +733,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink5WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the subscription level policy assignment. /// @@ -755,7 +755,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink6WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy states for the resource group level policy /// assignment. @@ -778,6 +778,6 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> NextLink7WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Attestation.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Attestation.cs new file mode 100644 index 0000000000000..f3af98f853d48 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Attestation.cs @@ -0,0 +1,177 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An attestation resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class Attestation : Resource + { + /// + /// Initializes a new instance of the Attestation class. + /// + public Attestation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Attestation class. + /// + /// The resource ID of the policy + /// assignment that the attestation is setting the state for. + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// The policy definition + /// reference ID from a policy set definition that the attestation is + /// setting the state for. If the policy assignment assigns a policy + /// set definition the attestation can choose a definition within the + /// set definition with this property or omit this and set the state + /// for the entire set definition. + /// The compliance state that should be + /// set on the resource. Possible values include: 'Compliant', + /// 'NonCompliant', 'Unknown' + /// The time the compliance state should + /// expire. + /// The person responsible for setting the state of + /// the resource. This value is typically an Azure Active Directory + /// object ID. + /// Comments describing why this attestation was + /// created. + /// The evidence supporting the compliance state + /// set in this attestation. + /// The status of the + /// attestation. + /// The time the compliance + /// state was last changed in this attestation. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + public Attestation(string policyAssignmentId, string id = default(string), string name = default(string), string type = default(string), string policyDefinitionReferenceId = default(string), string complianceState = default(string), System.DateTime? expiresOn = default(System.DateTime?), string owner = default(string), string comments = default(string), IList evidence = default(IList), string provisioningState = default(string), System.DateTime? lastComplianceStateChangeAt = default(System.DateTime?), SystemData systemData = default(SystemData)) + : base(id, name, type) + { + PolicyAssignmentId = policyAssignmentId; + PolicyDefinitionReferenceId = policyDefinitionReferenceId; + ComplianceState = complianceState; + ExpiresOn = expiresOn; + Owner = owner; + Comments = comments; + Evidence = evidence; + ProvisioningState = provisioningState; + LastComplianceStateChangeAt = lastComplianceStateChangeAt; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource ID of the policy assignment that the + /// attestation is setting the state for. + /// + [JsonProperty(PropertyName = "properties.policyAssignmentId")] + public string PolicyAssignmentId { get; set; } + + /// + /// Gets or sets the policy definition reference ID from a policy set + /// definition that the attestation is setting the state for. If the + /// policy assignment assigns a policy set definition the attestation + /// can choose a definition within the set definition with this + /// property or omit this and set the state for the entire set + /// definition. + /// + [JsonProperty(PropertyName = "properties.policyDefinitionReferenceId")] + public string PolicyDefinitionReferenceId { get; set; } + + /// + /// Gets or sets the compliance state that should be set on the + /// resource. Possible values include: 'Compliant', 'NonCompliant', + /// 'Unknown' + /// + [JsonProperty(PropertyName = "properties.complianceState")] + public string ComplianceState { get; set; } + + /// + /// Gets or sets the time the compliance state should expire. + /// + [JsonProperty(PropertyName = "properties.expiresOn")] + public System.DateTime? ExpiresOn { get; set; } + + /// + /// Gets or sets the person responsible for setting the state of the + /// resource. This value is typically an Azure Active Directory object + /// ID. + /// + [JsonProperty(PropertyName = "properties.owner")] + public string Owner { get; set; } + + /// + /// Gets or sets comments describing why this attestation was created. + /// + [JsonProperty(PropertyName = "properties.comments")] + public string Comments { get; set; } + + /// + /// Gets or sets the evidence supporting the compliance state set in + /// this attestation. + /// + [JsonProperty(PropertyName = "properties.evidence")] + public IList Evidence { get; set; } + + /// + /// Gets the status of the attestation. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the time the compliance state was last changed in this + /// attestation. + /// + [JsonProperty(PropertyName = "properties.lastComplianceStateChangeAt")] + public System.DateTime? LastComplianceStateChangeAt { get; private set; } + + /// + /// Gets azure Resource Manager metadata containing createdBy and + /// modifiedBy information. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PolicyAssignmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PolicyAssignmentId"); + } + } + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AttestationEvidence.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AttestationEvidence.cs new file mode 100644 index 0000000000000..d915db429aea1 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AttestationEvidence.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A piece of evidence supporting the compliance state set in the + /// attestation. + /// + public partial class AttestationEvidence + { + /// + /// Initializes a new instance of the AttestationEvidence class. + /// + public AttestationEvidence() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AttestationEvidence class. + /// + /// The description for this piece of + /// evidence. + /// The URI location of the evidence. + public AttestationEvidence(string description = default(string), string sourceUri = default(string)) + { + Description = description; + SourceUri = sourceUri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the description for this piece of evidence. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets the URI location of the evidence. + /// + [JsonProperty(PropertyName = "sourceUri")] + public string SourceUri { get; set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AzureEntityResource.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AzureEntityResource.cs new file mode 100644 index 0000000000000..21e217c61f2e6 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/AzureEntityResource.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity Resource + /// + /// + /// The resource model definition for an Azure Resource Manager resource + /// with an etag. + /// + public partial class AzureEntityResource : Resource + { + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + public AzureEntityResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource Etag. + public AzureEntityResource(string id = default(string), string name = default(string), string type = default(string), string etag = default(string)) + : base(id, name, type) + { + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsRequest.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsRequest.cs new file mode 100644 index 0000000000000..4dfcb41ef2283 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsRequest.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The check policy restrictions parameters describing the resource that + /// is being evaluated. + /// + public partial class CheckRestrictionsRequest + { + /// + /// Initializes a new instance of the CheckRestrictionsRequest class. + /// + public CheckRestrictionsRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckRestrictionsRequest class. + /// + /// The information about the resource + /// that will be evaluated. + /// The list of fields and values that + /// should be evaluated for potential restrictions. + public CheckRestrictionsRequest(CheckRestrictionsResourceDetails resourceDetails, IList pendingFields = default(IList)) + { + ResourceDetails = resourceDetails; + PendingFields = pendingFields; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the information about the resource that will be + /// evaluated. + /// + [JsonProperty(PropertyName = "resourceDetails")] + public CheckRestrictionsResourceDetails ResourceDetails { get; set; } + + /// + /// Gets or sets the list of fields and values that should be evaluated + /// for potential restrictions. + /// + [JsonProperty(PropertyName = "pendingFields")] + public IList PendingFields { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceDetails == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceDetails"); + } + if (ResourceDetails != null) + { + ResourceDetails.Validate(); + } + if (PendingFields != null) + { + foreach (var element in PendingFields) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResourceDetails.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResourceDetails.cs new file mode 100644 index 0000000000000..38c72215ce088 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResourceDetails.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.PolicyInsights.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The information about the resource that will be evaluated. + /// + public partial class CheckRestrictionsResourceDetails + { + /// + /// Initializes a new instance of the CheckRestrictionsResourceDetails + /// class. + /// + public CheckRestrictionsResourceDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckRestrictionsResourceDetails + /// class. + /// + /// The resource content. This should + /// include whatever properties are already known and can be a partial + /// set of all resource properties. + /// The api-version of the resource + /// content. + /// The scope where the resource is being created. + /// For example, if the resource is a child resource this would be the + /// parent resource's resource ID. + public CheckRestrictionsResourceDetails(object resourceContent, string apiVersion = default(string), string scope = default(string)) + { + ResourceContent = resourceContent; + ApiVersion = apiVersion; + Scope = scope; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource content. This should include whatever + /// properties are already known and can be a partial set of all + /// resource properties. + /// + [JsonProperty(PropertyName = "resourceContent")] + public object ResourceContent { get; set; } + + /// + /// Gets or sets the api-version of the resource content. + /// + [JsonProperty(PropertyName = "apiVersion")] + public string ApiVersion { get; set; } + + /// + /// Gets or sets the scope where the resource is being created. For + /// example, if the resource is a child resource this would be the + /// parent resource's resource ID. + /// + [JsonProperty(PropertyName = "scope")] + public string Scope { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceContent == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceContent"); + } + } + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResult.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResult.cs new file mode 100644 index 0000000000000..9016faf1818e9 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResult.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The result of a check policy restrictions evaluation on a resource. + /// + public partial class CheckRestrictionsResult + { + /// + /// Initializes a new instance of the CheckRestrictionsResult class. + /// + public CheckRestrictionsResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckRestrictionsResult class. + /// + /// The restrictions that will be + /// placed on various fields in the resource by policy. + /// Evaluation results for the + /// provided partial resource content. + public CheckRestrictionsResult(IList fieldRestrictions = default(IList), CheckRestrictionsResultContentEvaluationResult contentEvaluationResult = default(CheckRestrictionsResultContentEvaluationResult)) + { + FieldRestrictions = fieldRestrictions; + ContentEvaluationResult = contentEvaluationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the restrictions that will be placed on various fields in the + /// resource by policy. + /// + [JsonProperty(PropertyName = "fieldRestrictions")] + public IList FieldRestrictions { get; private set; } + + /// + /// Gets evaluation results for the provided partial resource content. + /// + [JsonProperty(PropertyName = "contentEvaluationResult")] + public CheckRestrictionsResultContentEvaluationResult ContentEvaluationResult { get; private set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResultContentEvaluationResult.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResultContentEvaluationResult.cs new file mode 100644 index 0000000000000..22a854ef35cf6 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CheckRestrictionsResultContentEvaluationResult.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Evaluation results for the provided partial resource content. + /// + public partial class CheckRestrictionsResultContentEvaluationResult + { + /// + /// Initializes a new instance of the + /// CheckRestrictionsResultContentEvaluationResult class. + /// + public CheckRestrictionsResultContentEvaluationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CheckRestrictionsResultContentEvaluationResult class. + /// + /// Policy evaluation results against + /// the given resource content. This will indicate if the partial + /// content that was provided will be denied as-is. + public CheckRestrictionsResultContentEvaluationResult(IList policyEvaluations = default(IList)) + { + PolicyEvaluations = policyEvaluations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets policy evaluation results against the given resource + /// content. This will indicate if the partial content that was + /// provided will be denied as-is. + /// + [JsonProperty(PropertyName = "policyEvaluations")] + public IList PolicyEvaluations { get; set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ComplianceState.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ComplianceState.cs new file mode 100644 index 0000000000000..0878a9e685cb4 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ComplianceState.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + + /// + /// Defines values for ComplianceState. + /// + public static class ComplianceState + { + /// + /// The resource is in compliance with the policy. + /// + public const string Compliant = "Compliant"; + /// + /// The resource is not in compliance with the policy. + /// + public const string NonCompliant = "NonCompliant"; + /// + /// The compliance state of the resource is not known. + /// + public const string Unknown = "Unknown"; + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CreatedByType.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CreatedByType.cs new file mode 100644 index 0000000000000..b1743cf0e267a --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/CreatedByType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ExpressionEvaluationDetails.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ExpressionEvaluationDetails.cs index bfcee28fd06fe..53038318f51b1 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ExpressionEvaluationDetails.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ExpressionEvaluationDetails.cs @@ -33,6 +33,8 @@ public ExpressionEvaluationDetails() /// /// Evaluation result. /// Expression evaluated. + /// The kind of expression that was + /// evaluated. /// Property path if the expression is a field or an /// alias. /// Value of the expression. @@ -40,10 +42,11 @@ public ExpressionEvaluationDetails() /// expression value. /// Operator to compare the expression /// value and the target value. - public ExpressionEvaluationDetails(string result = default(string), string expression = default(string), string path = default(string), object expressionValue = default(object), object targetValue = default(object), string operatorProperty = default(string)) + public ExpressionEvaluationDetails(string result = default(string), string expression = default(string), string expressionKind = default(string), string path = default(string), object expressionValue = default(object), object targetValue = default(object), string operatorProperty = default(string)) { Result = result; Expression = expression; + ExpressionKind = expressionKind; Path = path; ExpressionValue = expressionValue; TargetValue = targetValue; @@ -68,6 +71,12 @@ public ExpressionEvaluationDetails() [JsonProperty(PropertyName = "expression")] public string Expression { get; set; } + /// + /// Gets the kind of expression that was evaluated. + /// + [JsonProperty(PropertyName = "expressionKind")] + public string ExpressionKind { get; private set; } + /// /// Gets or sets property path if the expression is a field or an /// alias. diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestriction.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestriction.cs new file mode 100644 index 0000000000000..dd1e7178a607a --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestriction.cs @@ -0,0 +1,86 @@ +// +// 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.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The restrictions on a field imposed by a specific policy. + /// + public partial class FieldRestriction + { + /// + /// Initializes a new instance of the FieldRestriction class. + /// + public FieldRestriction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FieldRestriction class. + /// + /// The type of restriction that is imposed on the + /// field. Possible values include: 'Required', 'Removed', + /// 'Deny' + /// The value that policy will set for the + /// field if the user does not provide a value. + /// The values that policy either requires or + /// denies for the field. + /// The details of the policy that is causing the + /// field restriction. + public FieldRestriction(string result = default(string), string defaultValue = default(string), IList values = default(IList), PolicyReference policy = default(PolicyReference)) + { + Result = result; + DefaultValue = defaultValue; + Values = values; + Policy = policy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the type of restriction that is imposed on the field. Possible + /// values include: 'Required', 'Removed', 'Deny' + /// + [JsonProperty(PropertyName = "result")] + public string Result { get; private set; } + + /// + /// Gets the value that policy will set for the field if the user does + /// not provide a value. + /// + [JsonProperty(PropertyName = "defaultValue")] + public string DefaultValue { get; private set; } + + /// + /// Gets the values that policy either requires or denies for the + /// field. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; private set; } + + /// + /// Gets the details of the policy that is causing the field + /// restriction. + /// + [JsonProperty(PropertyName = "policy")] + public PolicyReference Policy { get; private set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictionResult.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictionResult.cs new file mode 100644 index 0000000000000..c0c9e03c296d8 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictionResult.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + + /// + /// Defines values for FieldRestrictionResult. + /// + public static class FieldRestrictionResult + { + /// + /// The field and/or values are required by policy. + /// + public const string Required = "Required"; + /// + /// The field will be removed by policy. + /// + public const string Removed = "Removed"; + /// + /// The field and/or values will be denied by policy. + /// + public const string Deny = "Deny"; + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictions.cs new file mode 100644 index 0000000000000..c55ffafa21392 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/FieldRestrictions.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The restrictions that will be placed on a field in the resource by + /// policy. + /// + public partial class FieldRestrictions + { + /// + /// Initializes a new instance of the FieldRestrictions class. + /// + public FieldRestrictions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FieldRestrictions class. + /// + /// The name of the field. This can be a top-level + /// property like 'name' or 'type' or an Azure Policy field + /// alias. + /// The restrictions placed on that field by + /// policy. + public FieldRestrictions(string field = default(string), IList restrictions = default(IList)) + { + Field = field; + Restrictions = restrictions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the field. This can be a top-level property like + /// 'name' or 'type' or an Azure Policy field alias. + /// + [JsonProperty(PropertyName = "field")] + public string Field { get; private set; } + + /// + /// Gets or sets the restrictions placed on that field by policy. + /// + [JsonProperty(PropertyName = "restrictions")] + public IList Restrictions { get; set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PendingField.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PendingField.cs new file mode 100644 index 0000000000000..854e36513ae83 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PendingField.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.PolicyInsights.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A field that should be evaluated against Azure Policy to determine + /// restrictions. + /// + public partial class PendingField + { + /// + /// Initializes a new instance of the PendingField class. + /// + public PendingField() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PendingField class. + /// + /// The name of the field. This can be a top-level + /// property like 'name' or 'type' or an Azure Policy field + /// alias. + /// The list of potential values for the field + /// that should be evaluated against Azure Policy. + public PendingField(string field, IList values = default(IList)) + { + Field = field; + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the field. This can be a top-level + /// property like 'name' or 'type' or an Azure Policy field alias. + /// + [JsonProperty(PropertyName = "field")] + public string Field { get; set; } + + /// + /// Gets or sets the list of potential values for the field that should + /// be evaluated against Azure Policy. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Field == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Field"); + } + } + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEvaluationResult.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEvaluationResult.cs new file mode 100644 index 0000000000000..cf9cd45d94ab7 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEvaluationResult.cs @@ -0,0 +1,75 @@ +// +// 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.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The result of a non-compliant policy evaluation against the given + /// resource content. + /// + public partial class PolicyEvaluationResult + { + /// + /// Initializes a new instance of the PolicyEvaluationResult class. + /// + public PolicyEvaluationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyEvaluationResult class. + /// + /// The details of the policy that was + /// evaluated. + /// The result of the policy evaluation + /// against the resource. This will typically be 'NonCompliant' but may + /// contain other values if errors were encountered. + /// The detailed results of the policy + /// expressions and values that were evaluated. + public PolicyEvaluationResult(PolicyReference policyInfo = default(PolicyReference), string evaluationResult = default(string), PolicyEvaluationDetails evaluationDetails = default(PolicyEvaluationDetails)) + { + PolicyInfo = policyInfo; + EvaluationResult = evaluationResult; + EvaluationDetails = evaluationDetails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the details of the policy that was evaluated. + /// + [JsonProperty(PropertyName = "policyInfo")] + public PolicyReference PolicyInfo { get; private set; } + + /// + /// Gets the result of the policy evaluation against the resource. This + /// will typically be 'NonCompliant' but may contain other values if + /// errors were encountered. + /// + [JsonProperty(PropertyName = "evaluationResult")] + public string EvaluationResult { get; private set; } + + /// + /// Gets the detailed results of the policy expressions and values that + /// were evaluated. + /// + [JsonProperty(PropertyName = "evaluationDetails")] + public PolicyEvaluationDetails EvaluationDetails { get; private set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyReference.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyReference.cs new file mode 100644 index 0000000000000..b496dd096e519 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyReference.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.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource identifiers for a policy. + /// + public partial class PolicyReference + { + /// + /// Initializes a new instance of the PolicyReference class. + /// + public PolicyReference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyReference class. + /// + /// The resource identifier of the + /// policy definition. + /// The resource identifier of the + /// policy set definition. + /// The reference identifier + /// of a specific policy definition within a policy set + /// definition. + /// The resource identifier of the + /// policy assignment. + public PolicyReference(string policyDefinitionId = default(string), string policySetDefinitionId = default(string), string policyDefinitionReferenceId = default(string), string policyAssignmentId = default(string)) + { + PolicyDefinitionId = policyDefinitionId; + PolicySetDefinitionId = policySetDefinitionId; + PolicyDefinitionReferenceId = policyDefinitionReferenceId; + PolicyAssignmentId = policyAssignmentId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource identifier of the policy definition. + /// + [JsonProperty(PropertyName = "policyDefinitionId")] + public string PolicyDefinitionId { get; private set; } + + /// + /// Gets the resource identifier of the policy set definition. + /// + [JsonProperty(PropertyName = "policySetDefinitionId")] + public string PolicySetDefinitionId { get; private set; } + + /// + /// Gets the reference identifier of a specific policy definition + /// within a policy set definition. + /// + [JsonProperty(PropertyName = "policyDefinitionReferenceId")] + public string PolicyDefinitionReferenceId { get; private set; } + + /// + /// Gets the resource identifier of the policy assignment. + /// + [JsonProperty(PropertyName = "policyAssignmentId")] + public string PolicyAssignmentId { get; private set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ProxyResource.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ProxyResource.cs new file mode 100644 index 0000000000000..01c9590b7cd81 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/ProxyResource.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using System.Linq; + + /// + /// Proxy Resource + /// + /// + /// The resource model definition for a Azure Resource Manager proxy + /// resource. It will not have tags and a location + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Resource.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Resource.cs new file mode 100644 index 0000000000000..e9129e32229bb --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Resource.cs @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource + /// + /// + /// Common fields that are returned in the response for all Azure Resource + /// Manager resources + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public Resource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/SystemData.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/SystemData.cs new file mode 100644 index 0000000000000..c89991eefa0f0 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/TrackedResource.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/TrackedResource.cs new file mode 100644 index 0000000000000..06944c9077a59 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/TrackedResource.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tracked Resource + /// + /// + /// The resource model definition for an Azure Resource Manager tracked top + /// level resource which has 'tags' and a 'location' + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource tags. + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the geo-location where the resource lives + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs index 3547e31842898..b5882343811cc 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs @@ -2244,7 +2244,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLinkWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -2259,7 +2259,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForManagementGroupNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -2412,7 +2412,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink1WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -2427,7 +2427,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink1", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -2580,7 +2580,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink2WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -2595,7 +2595,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink2", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -2748,7 +2748,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink3WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -2763,7 +2763,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink3", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -2916,7 +2916,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink4WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -2931,7 +2931,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicySetDefinitionNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink4", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -3084,7 +3084,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink5WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -3099,7 +3099,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicyDefinitionNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink5", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -3252,7 +3252,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink6WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -3267,7 +3267,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionLevelPolicyAssignmentNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink6", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -3420,7 +3420,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink7WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -3435,7 +3435,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupLevelPolicyAssignmentNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink7", tracingParameters); } // Construct URL string _url = "{nextLink}"; diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs index 2103d7ebc7127..8ec53c4ecb292 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs @@ -386,9 +386,9 @@ public static partial class PolicyEventsOperationsExtensions /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForManagementGroupNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLinkAsync(nextPageLink).GetAwaiter().GetResult(); } /// @@ -403,9 +403,9 @@ public static IPage ListQueryResultsForManagementGroupNext(this IPo /// /// The cancellation token. /// - public static async Task> ListQueryResultsForManagementGroupNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLinkAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLinkWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -420,9 +420,9 @@ public static IPage ListQueryResultsForManagementGroupNext(this IPo /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForSubscriptionNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink1(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForSubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink1Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -437,9 +437,9 @@ public static IPage ListQueryResultsForSubscriptionNext(this IPolic /// /// The cancellation token. /// - public static async Task> ListQueryResultsForSubscriptionNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink1Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink1WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -454,9 +454,9 @@ public static IPage ListQueryResultsForSubscriptionNext(this IPolic /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForResourceGroupNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink2(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink2Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -471,9 +471,9 @@ public static IPage ListQueryResultsForResourceGroupNext(this IPoli /// /// The cancellation token. /// - public static async Task> ListQueryResultsForResourceGroupNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink2Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink2WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -488,9 +488,9 @@ public static IPage ListQueryResultsForResourceGroupNext(this IPoli /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForResourceNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink3(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink3Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -505,9 +505,9 @@ public static IPage ListQueryResultsForResourceNext(this IPolicyEve /// /// The cancellation token. /// - public static async Task> ListQueryResultsForResourceNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink3Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink3WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -522,9 +522,9 @@ public static IPage ListQueryResultsForResourceNext(this IPolicyEve /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForPolicySetDefinitionNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink4(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForPolicySetDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink4Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -539,9 +539,9 @@ public static IPage ListQueryResultsForPolicySetDefinitionNext(this /// /// The cancellation token. /// - public static async Task> ListQueryResultsForPolicySetDefinitionNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink4Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink4WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -556,9 +556,9 @@ public static IPage ListQueryResultsForPolicySetDefinitionNext(this /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForPolicyDefinitionNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink5(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForPolicyDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink5Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -573,9 +573,9 @@ public static IPage ListQueryResultsForPolicyDefinitionNext(this IP /// /// The cancellation token. /// - public static async Task> ListQueryResultsForPolicyDefinitionNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink5Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink5WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -590,9 +590,9 @@ public static IPage ListQueryResultsForPolicyDefinitionNext(this IP /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForSubscriptionLevelPolicyAssignmentNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink6(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink6Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -607,9 +607,9 @@ public static IPage ListQueryResultsForSubscriptionLevelPolicyAssig /// /// The cancellation token. /// - public static async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink6Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink6WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -624,9 +624,9 @@ public static IPage ListQueryResultsForSubscriptionLevelPolicyAssig /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForResourceGroupLevelPolicyAssignmentNext(this IPolicyEventsOperations operations, string nextPageLink) + public static IPage NextLink7(this IPolicyEventsOperations operations, string nextPageLink) { - return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink7Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -641,9 +641,9 @@ public static IPage ListQueryResultsForResourceGroupLevelPolicyAssi /// /// The cancellation token. /// - public static async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink7Async(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink7WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyInsightsClient.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyInsightsClient.cs index bcea4394e4ccc..43a27cbd9875e 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyInsightsClient.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyInsightsClient.cs @@ -43,6 +43,11 @@ public partial class PolicyInsightsClient : ServiceClient, /// public ServiceClientCredentials Credentials { get; private set; } + /// + /// The ID of the target subscription. + /// + public string SubscriptionId2 { get; set; } + /// /// The preferred language for the response. /// @@ -91,6 +96,16 @@ public partial class PolicyInsightsClient : ServiceClient, /// public virtual IPolicyMetadataOperations PolicyMetadata { get; private set; } + /// + /// Gets the IPolicyRestrictionsOperations. + /// + public virtual IPolicyRestrictionsOperations PolicyRestrictions { get; private set; } + + /// + /// Gets the IAttestationsOperations. + /// + public virtual IAttestationsOperations Attestations { get; private set; } + /// /// Initializes a new instance of the PolicyInsightsClient class. /// @@ -338,6 +353,8 @@ private void Initialize() PolicyStates = new PolicyStatesOperations(this); Operations = new Operations(this); PolicyMetadata = new PolicyMetadataOperations(this); + PolicyRestrictions = new PolicyRestrictionsOperations(this); + Attestations = new AttestationsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperations.cs new file mode 100644 index 0000000000000..46719bc87086c --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperations.cs @@ -0,0 +1,477 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights +{ + 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; + + /// + /// PolicyRestrictionsOperations operations. + /// + internal partial class PolicyRestrictionsOperations : IServiceOperations, IPolicyRestrictionsOperations + { + /// + /// Initializes a new instance of the PolicyRestrictionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PolicyRestrictionsOperations(PolicyInsightsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyInsightsClient + /// + public PolicyInsightsClient Client { get; private set; } + + /// + /// Checks what restrictions Azure Policy will place on a resource within a + /// subscription. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The check policy restrictions parameters. + /// + /// + /// 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> CheckAtSubscriptionScopeWithHttpMessagesAsync(string subscriptionId, CheckRestrictionsRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2020-07-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("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions").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; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Checks what restrictions Azure Policy will place on a resource within a + /// resource group. Use this when the resource group the resource will be + /// created in is already known. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The check policy restrictions parameters. + /// + /// + /// 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> CheckAtResourceGroupScopeWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, CheckRestrictionsRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (subscriptionId != null) + { + if (subscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "subscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2020-07-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("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckAtResourceGroupScope", 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/checkPolicyRestrictions").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; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperationsExtensions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperationsExtensions.cs new file mode 100644 index 0000000000000..289cb05b148ca --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyRestrictionsOperationsExtensions.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PolicyRestrictionsOperations. + /// + public static partial class PolicyRestrictionsOperationsExtensions + { + /// + /// Checks what restrictions Azure Policy will place on a resource within a + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The check policy restrictions parameters. + /// + public static CheckRestrictionsResult CheckAtSubscriptionScope(this IPolicyRestrictionsOperations operations, string subscriptionId, CheckRestrictionsRequest parameters) + { + return operations.CheckAtSubscriptionScopeAsync(subscriptionId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Checks what restrictions Azure Policy will place on a resource within a + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The check policy restrictions parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CheckAtSubscriptionScopeAsync(this IPolicyRestrictionsOperations operations, string subscriptionId, CheckRestrictionsRequest parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckAtSubscriptionScopeWithHttpMessagesAsync(subscriptionId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks what restrictions Azure Policy will place on a resource within a + /// resource group. Use this when the resource group the resource will be + /// created in is already known. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The check policy restrictions parameters. + /// + public static CheckRestrictionsResult CheckAtResourceGroupScope(this IPolicyRestrictionsOperations operations, string subscriptionId, string resourceGroupName, CheckRestrictionsRequest parameters) + { + return operations.CheckAtResourceGroupScopeAsync(subscriptionId, resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Checks what restrictions Azure Policy will place on a resource within a + /// resource group. Use this when the resource group the resource will be + /// created in is already known. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The check policy restrictions parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CheckAtResourceGroupScopeAsync(this IPolicyRestrictionsOperations operations, string subscriptionId, string resourceGroupName, CheckRestrictionsRequest parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckAtResourceGroupScopeWithHttpMessagesAsync(subscriptionId, resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} 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 d7e6ec67c539f..bfbe757cea912 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs @@ -4515,7 +4515,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLinkWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -4530,7 +4530,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForManagementGroupNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -4683,7 +4683,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink1WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -4698,7 +4698,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink1", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -4851,7 +4851,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink2WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -4866,7 +4866,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink2", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -5019,7 +5019,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink3WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -5034,7 +5034,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink3", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -5187,7 +5187,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink4WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -5202,7 +5202,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicySetDefinitionNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink4", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -5355,7 +5355,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink5WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -5370,7 +5370,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicyDefinitionNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink5", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -5523,7 +5523,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink6WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -5538,7 +5538,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionLevelPolicyAssignmentNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink6", tracingParameters); } // Construct URL string _url = "{nextLink}"; @@ -5691,7 +5691,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> NextLink7WithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (nextPageLink == null) { @@ -5706,7 +5706,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupLevelPolicyAssignmentNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "NextLink7", tracingParameters); } // Construct URL string _url = "{nextLink}"; 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 0d96e68dc822b..698e66a1a4a18 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs @@ -982,9 +982,9 @@ public static void BeginTriggerResourceGroupEvaluation(this IPolicyStatesOperati /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForManagementGroupNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLinkAsync(nextPageLink).GetAwaiter().GetResult(); } /// @@ -999,9 +999,9 @@ public static IPage ListQueryResultsForManagementGroupNext(this IPo /// /// The cancellation token. /// - public static async Task> ListQueryResultsForManagementGroupNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLinkAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLinkWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1016,9 +1016,9 @@ public static IPage ListQueryResultsForManagementGroupNext(this IPo /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForSubscriptionNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink1(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForSubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink1Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1033,9 +1033,9 @@ public static IPage ListQueryResultsForSubscriptionNext(this IPolic /// /// The cancellation token. /// - public static async Task> ListQueryResultsForSubscriptionNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink1Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink1WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1050,9 +1050,9 @@ public static IPage ListQueryResultsForSubscriptionNext(this IPolic /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForResourceGroupNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink2(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink2Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1067,9 +1067,9 @@ public static IPage ListQueryResultsForResourceGroupNext(this IPoli /// /// The cancellation token. /// - public static async Task> ListQueryResultsForResourceGroupNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink2Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink2WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1084,9 +1084,9 @@ public static IPage ListQueryResultsForResourceGroupNext(this IPoli /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForResourceNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink3(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink3Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1101,9 +1101,9 @@ public static IPage ListQueryResultsForResourceNext(this IPolicySta /// /// The cancellation token. /// - public static async Task> ListQueryResultsForResourceNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink3Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink3WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1118,9 +1118,9 @@ public static IPage ListQueryResultsForResourceNext(this IPolicySta /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForPolicySetDefinitionNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink4(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForPolicySetDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink4Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1135,9 +1135,9 @@ public static IPage ListQueryResultsForPolicySetDefinitionNext(this /// /// The cancellation token. /// - public static async Task> ListQueryResultsForPolicySetDefinitionNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink4Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink4WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1152,9 +1152,9 @@ public static IPage ListQueryResultsForPolicySetDefinitionNext(this /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForPolicyDefinitionNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink5(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForPolicyDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink5Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1169,9 +1169,9 @@ public static IPage ListQueryResultsForPolicyDefinitionNext(this IP /// /// The cancellation token. /// - public static async Task> ListQueryResultsForPolicyDefinitionNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink5Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink5WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1186,9 +1186,9 @@ public static IPage ListQueryResultsForPolicyDefinitionNext(this IP /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForSubscriptionLevelPolicyAssignmentNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink6(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink6Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1203,9 +1203,9 @@ public static IPage ListQueryResultsForSubscriptionLevelPolicyAssig /// /// The cancellation token. /// - public static async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink6Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink6WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -1220,9 +1220,9 @@ public static IPage ListQueryResultsForSubscriptionLevelPolicyAssig /// /// The NextLink from the previous successful call to List operation. /// - public static IPage ListQueryResultsForResourceGroupLevelPolicyAssignmentNext(this IPolicyStatesOperations operations, string nextPageLink) + public static IPage NextLink7(this IPolicyStatesOperations operations, string nextPageLink) { - return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + return operations.NextLink7Async(nextPageLink).GetAwaiter().GetResult(); } /// @@ -1237,9 +1237,9 @@ public static IPage ListQueryResultsForResourceGroupLevelPolicyAssi /// /// The cancellation token. /// - public static async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> NextLink7Async(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.NextLink7WithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } 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 7b12a4b899305..ea9a77c918e46 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 @@ -19,25 +19,16 @@ public static IEnumerable> ApiInfo_PolicyInsightsC { return new Tuple[] { + new Tuple("PolicyInsights", "Attestations", "2021-01-01"), new Tuple("PolicyInsights", "Operations", "2019-10-01"), new Tuple("PolicyInsights", "PolicyEvents", "2019-10-01"), new Tuple("PolicyInsights", "PolicyMetadata", "2019-10-01"), + new Tuple("PolicyInsights", "PolicyRestrictions", "2020-07-01"), new Tuple("PolicyInsights", "PolicyStates", "2019-10-01"), new Tuple("PolicyInsights", "PolicyTrackedResources", "2018-07-01-preview"), new Tuple("PolicyInsights", "Remediations", "2019-07-01"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@1.9.1"; - 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=v2 --reflect-api-versions --csharp-sdks-folder=C:\\Git\\narinem\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "5d6c5386b27452b887d203e8f8238b64a31e4206"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } -