diff --git a/src/ResourceManager/Version2018_05_01/IPolicyAssignmentsOperations.cs b/src/ResourceManager/Version2018_05_01/IPolicyAssignmentsOperations.cs
new file mode 100644
index 0000000000..ebb38dee85
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/IPolicyAssignmentsOperations.cs
@@ -0,0 +1,545 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Azure.OData;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicyAssignmentsOperations operations.
+ ///
+ public partial interface IPolicyAssignmentsOperations
+ {
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes a policy assignment, given its name and the
+ /// scope it was created in. The scope of a policy assignment is the
+ /// part of its ID preceding
+ /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management
+ /// group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource
+ /// group (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}',
+ /// or resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to delete.
+ ///
+ ///
+ /// 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> DeleteWithHttpMessagesAsync(string scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Creates or updates a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates a policy assignment with the
+ /// given scope and name. Policy assignments apply to all resources
+ /// contained within their scope. For example, when you assign a policy
+ /// at resource group scope, that policy applies to all resources in
+ /// the group.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management
+ /// group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource
+ /// group (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}',
+ /// or resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment.
+ ///
+ ///
+ /// Parameters for the policy assignment.
+ ///
+ ///
+ /// 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> CreateWithHttpMessagesAsync(string scope, string policyAssignmentName, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves a policy assignment.
+ ///
+ ///
+ /// This operation retrieves a single policy assignment, given its name
+ /// and the scope it was created at.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management
+ /// group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource
+ /// group (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}',
+ /// or resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to get.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments
+ /// associated with the given resource group in the given subscription
+ /// that match the optional given $filter. Valid values for $filter
+ /// are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
+ /// is not provided, the unfiltered list includes all policy
+ /// assignments associated with the resource group, including those
+ /// that apply directly or apply from containing scopes, as well as any
+ /// applied to resources contained within the resource group. If
+ /// $filter=atScope() is provided, the returned list includes all
+ /// policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId
+ /// eq '{value}' is provided, the returned list includes only policy
+ /// assignments that apply to the resource group and assign the policy
+ /// definition whose id is {value}.
+ ///
+ ///
+ /// The name of the resource group that contains policy assignments.
+ ///
+ ///
+ /// The filter to apply on the operation. Valid values for $filter are:
+ /// 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not
+ /// provided, no filtering is performed.
+ ///
+ ///
+ /// 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 resourceGroupName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments
+ /// associated with the specified resource in the given resource group
+ /// and subscription that match the optional given $filter. Valid
+ /// values for $filter are: 'atScope()' or 'policyDefinitionId eq
+ /// '{value}''. If $filter is not provided, the unfiltered list
+ /// includes all policy assignments associated with the resource,
+ /// including those that apply directly or from all containing scopes,
+ /// as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all
+ /// policy assignments that apply to the resource, which is everything
+ /// in the unfiltered list except those applied to resources contained
+ /// within the resource. If $filter=policyDefinitionId eq '{value}' is
+ /// provided, the returned list includes only policy assignments that
+ /// apply to the resource and assign the policy definition whose id is
+ /// {value}. Three parameters plus the resource name are used to
+ /// identify a specific resource. If the resource is not part of a
+ /// parent resource (the more common case), the parent resource path
+ /// should not be provided (or provided as ''). For example a web app
+ /// could be specified as ({resourceProviderNamespace} ==
+ /// 'Microsoft.Web', {parentResourcePath} == '', {resourceType} ==
+ /// 'sites', {resourceName} == 'MyWebApp'). If the resource is part of
+ /// a parent resource, then all parameters should be provided. For
+ /// example a virtual machine DNS name could be specified as
+ /// ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine',
+ /// {resourceType} == 'domainNames', {resourceName} ==
+ /// 'MyComputerName'). A convenient alternative to providing the
+ /// namespace and type name separately is to provide both in the
+ /// {resourceType} parameter, format: ({resourceProviderNamespace} ==
+ /// '', {parentResourcePath} == '', {resourceType} ==
+ /// 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// The name of the resource group containing the resource.
+ ///
+ ///
+ /// The namespace of the resource provider. For example, the namespace
+ /// of a virtual machine is Microsoft.Compute (from
+ /// Microsoft.Compute/virtualMachines)
+ ///
+ ///
+ /// The parent resource path. Use empty string if there is none.
+ ///
+ ///
+ /// The resource type name. For example the type name of a web app is
+ /// 'sites' (from Microsoft.Web/sites).
+ ///
+ ///
+ /// The name of the resource.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListForResourceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments
+ /// associated with the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// subscription, including those that apply directly or from
+ /// management groups that contain the given subscription, as well as
+ /// any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all
+ /// policy assignments that apply to the subscription, which is
+ /// everything in the unfiltered list except those applied to objects
+ /// contained within the subscription. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy
+ /// assignments that apply to the subscription and assign the policy
+ /// definition whose id is {value}.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes the policy with the given ID. Policy
+ /// assignment IDs have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid formats for {scope} are:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'
+ /// (management group), '/subscriptions/{subscriptionId}'
+ /// (subscription),
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
+ /// (resource group), or
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ /// (resource).
+ ///
+ ///
+ /// The ID of the policy assignment to delete. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// 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> DeleteByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Creates or updates a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates the policy assignment with the
+ /// given ID. Policy assignments made on a scope apply to all resources
+ /// contained in that scope. For example, when you assign a policy to a
+ /// resource group that policy applies to all resources in the group.
+ /// Policy assignment IDs have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource
+ /// group (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}',
+ /// or resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The ID of the policy assignment to create. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// Parameters for policy assignment.
+ ///
+ ///
+ /// 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> CreateByIdWithHttpMessagesAsync(string policyAssignmentId, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves the policy assignment with the given ID.
+ ///
+ ///
+ /// The operation retrieves the policy assignment with the given ID.
+ /// Policy assignment IDs have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource
+ /// group (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}',
+ /// or resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The ID of the policy assignment to get. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// 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> GetByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments
+ /// associated with the given resource group in the given subscription
+ /// that match the optional given $filter. Valid values for $filter
+ /// are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
+ /// is not provided, the unfiltered list includes all policy
+ /// assignments associated with the resource group, including those
+ /// that apply directly or apply from containing scopes, as well as any
+ /// applied to resources contained within the resource group. If
+ /// $filter=atScope() is provided, the returned list includes all
+ /// policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId
+ /// eq '{value}' is provided, the returned list includes only policy
+ /// assignments that apply to the resource group and assign the policy
+ /// definition whose id is {value}.
+ ///
+ ///
+ /// 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));
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments
+ /// associated with the specified resource in the given resource group
+ /// and subscription that match the optional given $filter. Valid
+ /// values for $filter are: 'atScope()' or 'policyDefinitionId eq
+ /// '{value}''. If $filter is not provided, the unfiltered list
+ /// includes all policy assignments associated with the resource,
+ /// including those that apply directly or from all containing scopes,
+ /// as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all
+ /// policy assignments that apply to the resource, which is everything
+ /// in the unfiltered list except those applied to resources contained
+ /// within the resource. If $filter=policyDefinitionId eq '{value}' is
+ /// provided, the returned list includes only policy assignments that
+ /// apply to the resource and assign the policy definition whose id is
+ /// {value}. Three parameters plus the resource name are used to
+ /// identify a specific resource. If the resource is not part of a
+ /// parent resource (the more common case), the parent resource path
+ /// should not be provided (or provided as ''). For example a web app
+ /// could be specified as ({resourceProviderNamespace} ==
+ /// 'Microsoft.Web', {parentResourcePath} == '', {resourceType} ==
+ /// 'sites', {resourceName} == 'MyWebApp'). If the resource is part of
+ /// a parent resource, then all parameters should be provided. For
+ /// example a virtual machine DNS name could be specified as
+ /// ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine',
+ /// {resourceType} == 'domainNames', {resourceName} ==
+ /// 'MyComputerName'). A convenient alternative to providing the
+ /// namespace and type name separately is to provide both in the
+ /// {resourceType} parameter, format: ({resourceProviderNamespace} ==
+ /// '', {parentResourcePath} == '', {resourceType} ==
+ /// 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// 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));
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments
+ /// associated with the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// subscription, including those that apply directly or from
+ /// management groups that contain the given subscription, as well as
+ /// any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all
+ /// policy assignments that apply to the subscription, which is
+ /// everything in the unfiltered list except those applied to objects
+ /// contained within the subscription. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy
+ /// assignments that apply to the subscription and assign the policy
+ /// definition whose id is {value}.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/IPolicyClient.cs b/src/ResourceManager/Version2018_05_01/IPolicyClient.cs
new file mode 100644
index 0000000000..93fcd8b5e3
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/IPolicyClient.cs
@@ -0,0 +1,89 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+
+ ///
+ /// To manage and control access to your resources, you can define
+ /// customized policies and assign them at a scope.
+ ///
+ public partial interface IPolicyClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ ServiceClientCredentials Credentials { get; }
+
+ ///
+ /// The ID of the target subscription.
+ ///
+ string SubscriptionId { get; set; }
+
+ ///
+ /// The API version to use for the operation.
+ ///
+ string ApiVersion { get; }
+
+ ///
+ /// The preferred language for the response.
+ ///
+ string AcceptLanguage { get; set; }
+
+ ///
+ /// The retry timeout in seconds for Long Running Operations. Default
+ /// value is 30.
+ ///
+ int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// Whether a unique x-ms-client-request-id should be generated. When
+ /// set to true a unique x-ms-client-request-id value is generated and
+ /// included in each request. Default is true.
+ ///
+ bool? GenerateClientRequestId { get; set; }
+
+
+ ///
+ /// Gets the IPolicyAssignmentsOperations.
+ ///
+ IPolicyAssignmentsOperations PolicyAssignments { get; }
+
+ ///
+ /// Gets the IPolicyDefinitionsOperations.
+ ///
+ IPolicyDefinitionsOperations PolicyDefinitions { get; }
+
+ ///
+ /// Gets the IPolicySetDefinitionsOperations.
+ ///
+ IPolicySetDefinitionsOperations PolicySetDefinitions { get; }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/IPolicyDefinitionsOperations.cs b/src/ResourceManager/Version2018_05_01/IPolicyDefinitionsOperations.cs
new file mode 100644
index 0000000000..ed3a9eef80
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/IPolicyDefinitionsOperations.cs
@@ -0,0 +1,368 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicyDefinitionsOperations operations.
+ ///
+ public partial interface IPolicyDefinitionsOperations
+ {
+ ///
+ /// Creates or updates a policy definition in a subscription.
+ ///
+ ///
+ /// This operation creates or updates a policy definition in the given
+ /// subscription with the given name.
+ ///
+ ///
+ /// The name of the policy definition to create.
+ ///
+ ///
+ /// The policy definition properties.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> CreateOrUpdateWithHttpMessagesAsync(string policyDefinitionName, PolicyDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Deletes a policy definition in a subscription.
+ ///
+ ///
+ /// This operation deletes the policy definition in the given
+ /// subscription with the given name.
+ ///
+ ///
+ /// The name of the policy definition to delete.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task DeleteWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves a policy definition in a subscription.
+ ///
+ ///
+ /// This operation retrieves the policy definition in the given
+ /// subscription with the given name.
+ ///
+ ///
+ /// The name of the policy definition to get.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves a built-in policy definition.
+ ///
+ ///
+ /// This operation retrieves the built-in policy definition with the
+ /// given name.
+ ///
+ ///
+ /// The name of the built-in policy definition to get.
+ ///
+ ///
+ /// 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> GetBuiltInWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Creates or updates a policy definition in a management group.
+ ///
+ ///
+ /// This operation creates or updates a policy definition in the given
+ /// management group with the given name.
+ ///
+ ///
+ /// The name of the policy definition to create.
+ ///
+ ///
+ /// The policy definition properties.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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> CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, PolicyDefinition parameters, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Deletes a policy definition in a management group.
+ ///
+ ///
+ /// This operation deletes the policy definition in the given
+ /// management group with the given name.
+ ///
+ ///
+ /// The name of the policy definition to delete.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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 DeleteAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve a policy definition in a management group.
+ ///
+ ///
+ /// This operation retrieves the policy definition in the given
+ /// management group with the given name.
+ ///
+ ///
+ /// The name of the policy definition to get.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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> GetAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves policy definitions in a subscription
+ ///
+ ///
+ /// This operation retrieves a list of all the policy definitions in a
+ /// given subscription.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve built-in policy definitions
+ ///
+ ///
+ /// This operation retrieves a list of all the built-in policy
+ /// definitions.
+ ///
+ ///
+ /// 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>> ListBuiltInWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve policy definitions in a management group
+ ///
+ ///
+ /// This operation retrieves a list of all the policy definitions in a
+ /// given management group.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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>> ListByManagementGroupWithHttpMessagesAsync(string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves policy definitions in a subscription
+ ///
+ ///
+ /// This operation retrieves a list of all the policy definitions in a
+ /// given subscription.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve built-in policy definitions
+ ///
+ ///
+ /// This operation retrieves a list of all the built-in policy
+ /// definitions.
+ ///
+ ///
+ /// 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>> ListBuiltInNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve policy definitions in a management group
+ ///
+ ///
+ /// This operation retrieves a list of all the policy definitions in a
+ /// given management 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>> ListByManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/IPolicySetDefinitionsOperations.cs b/src/ResourceManager/Version2018_05_01/IPolicySetDefinitionsOperations.cs
new file mode 100644
index 0000000000..e42a0bddc6
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/IPolicySetDefinitionsOperations.cs
@@ -0,0 +1,368 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicySetDefinitionsOperations operations.
+ ///
+ public partial interface IPolicySetDefinitionsOperations
+ {
+ ///
+ /// Creates or updates a policy set definition.
+ ///
+ ///
+ /// This operation creates or updates a policy set definition in the
+ /// given subscription with the given name.
+ ///
+ ///
+ /// The name of the policy set definition to create.
+ ///
+ ///
+ /// The policy set definition properties.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> CreateOrUpdateWithHttpMessagesAsync(string policySetDefinitionName, PolicySetDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Deletes a policy set definition.
+ ///
+ ///
+ /// This operation deletes the policy set definition in the given
+ /// subscription with the given name.
+ ///
+ ///
+ /// The name of the policy set definition to delete.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task DeleteWithHttpMessagesAsync(string policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves a policy set definition.
+ ///
+ ///
+ /// This operation retrieves the policy set definition in the given
+ /// subscription with the given name.
+ ///
+ ///
+ /// The name of the policy set definition to get.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves a built in policy set definition.
+ ///
+ ///
+ /// This operation retrieves the built-in policy set definition with
+ /// the given name.
+ ///
+ ///
+ /// The name of the policy set definition to get.
+ ///
+ ///
+ /// 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> GetBuiltInWithHttpMessagesAsync(string policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves the policy set definitions for a subscription.
+ ///
+ ///
+ /// This operation retrieves a list of all the policy set definitions
+ /// in the given subscription.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves built-in policy set definitions.
+ ///
+ ///
+ /// This operation retrieves a list of all the built-in policy set
+ /// definitions.
+ ///
+ ///
+ /// 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>> ListBuiltInWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Creates or updates a policy set definition.
+ ///
+ ///
+ /// This operation creates or updates a policy set definition in the
+ /// given management group with the given name.
+ ///
+ ///
+ /// The name of the policy set definition to create.
+ ///
+ ///
+ /// The policy set definition properties.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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> CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, PolicySetDefinition parameters, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Deletes a policy set definition.
+ ///
+ ///
+ /// This operation deletes the policy set definition in the given
+ /// management group with the given name.
+ ///
+ ///
+ /// The name of the policy set definition to delete.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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 DeleteAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves a policy set definition.
+ ///
+ ///
+ /// This operation retrieves the policy set definition in the given
+ /// management group with the given name.
+ ///
+ ///
+ /// The name of the policy set definition to get.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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> GetAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves all policy set definitions in management group.
+ ///
+ ///
+ /// This operation retrieves a list of all the a policy set definition
+ /// in the given management group.
+ ///
+ ///
+ /// The ID of the management group.
+ ///
+ ///
+ /// 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>> ListByManagementGroupWithHttpMessagesAsync(string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves the policy set definitions for a subscription.
+ ///
+ ///
+ /// This operation retrieves a list of all the policy set definitions
+ /// in the given subscription.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves built-in policy set definitions.
+ ///
+ ///
+ /// This operation retrieves a list of all the built-in policy set
+ /// definitions.
+ ///
+ ///
+ /// 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>> ListBuiltInNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieves all policy set definitions in management group.
+ ///
+ ///
+ /// This operation retrieves a list of all the a policy set definition
+ /// in the given management 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>> ListByManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/ErrorResponse.cs b/src/ResourceManager/Version2018_05_01/Models/ErrorResponse.cs
new file mode 100644
index 0000000000..4c988a0687
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/ErrorResponse.cs
@@ -0,0 +1,69 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Error response indicates Azure Resource Manager is not able to process
+ /// the incoming request. The reason is provided in the error message.
+ ///
+ public partial class ErrorResponse
+ {
+ ///
+ /// Initializes a new instance of the ErrorResponse class.
+ ///
+ public ErrorResponse()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponse class.
+ ///
+ /// Http status code.
+ /// Error code.
+ /// Error message indicating why the
+ /// operation failed.
+ public ErrorResponse(string httpStatus = default(string), string errorCode = default(string), string errorMessage = default(string))
+ {
+ HttpStatus = httpStatus;
+ ErrorCode = errorCode;
+ ErrorMessage = errorMessage;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets http status code.
+ ///
+ [JsonProperty(PropertyName = "httpStatus")]
+ public string HttpStatus { get; set; }
+
+ ///
+ /// Gets or sets error code.
+ ///
+ [JsonProperty(PropertyName = "errorCode")]
+ public string ErrorCode { get; set; }
+
+ ///
+ /// Gets or sets error message indicating why the operation failed.
+ ///
+ [JsonProperty(PropertyName = "errorMessage")]
+ public string ErrorMessage { get; set; }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/ErrorResponseException.cs b/src/ResourceManager/Version2018_05_01/Models/ErrorResponseException.cs
new file mode 100644
index 0000000000..9a600a2db9
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/ErrorResponseException.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.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Microsoft.Rest;
+
+ ///
+ /// Exception thrown for an invalid response with ErrorResponse
+ /// information.
+ ///
+ public partial class ErrorResponseException : RestException
+ {
+ ///
+ /// Gets information about the associated HTTP request.
+ ///
+ public HttpRequestMessageWrapper Request { get; set; }
+
+ ///
+ /// Gets information about the associated HTTP response.
+ ///
+ public HttpResponseMessageWrapper Response { get; set; }
+
+ ///
+ /// Gets or sets the body object.
+ ///
+ public ErrorResponse Body { get; set; }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ public ErrorResponseException()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// The exception message.
+ public ErrorResponseException(string message)
+ : this(message, null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// The exception message.
+ /// Inner exception.
+ public ErrorResponseException(string message, System.Exception innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicyAssignment.cs b/src/ResourceManager/Version2018_05_01/Models/PolicyAssignment.cs
new file mode 100644
index 0000000000..b0a4f8eede
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicyAssignment.cs
@@ -0,0 +1,178 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// The policy assignment.
+ ///
+ [Rest.Serialization.JsonTransformation]
+ public partial class PolicyAssignment : IResource
+ {
+ ///
+ /// Initializes a new instance of the PolicyAssignment class.
+ ///
+ public PolicyAssignment()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyAssignment class.
+ ///
+ /// The display name of the policy
+ /// assignment.
+ /// The ID of the policy definition or
+ /// policy set definition being assigned.
+ /// The scope for the policy assignment.
+ /// The policy's excluded scopes.
+ /// Required if a parameter is used in policy
+ /// rule.
+ /// This message will be part of response in
+ /// case of policy violation.
+ /// The policy assignment metadata.
+ /// The ID of the policy assignment.
+ /// The type of the policy assignment.
+ /// The name of the policy assignment.
+ /// The policy sku. This property is optional,
+ /// obsolete, and will be ignored.
+ /// The location of the policy assignment. Only
+ /// required when utilizing managed identity.
+ /// The managed identity associated with the
+ /// policy assignment.
+ public PolicyAssignment(string displayName = default(string), string policyDefinitionId = default(string), string scope = default(string), IList notScopes = default(IList), object parameters = default(object), string description = default(string), object metadata = default(object), string id = default(string), string type = default(string), string name = default(string), PolicySku sku = default(PolicySku), string location = default(string), Identity identity = default(Identity))
+ {
+ DisplayName = displayName;
+ PolicyDefinitionId = policyDefinitionId;
+ Scope = scope;
+ NotScopes = notScopes;
+ Parameters = parameters;
+ Description = description;
+ Metadata = metadata;
+ Id = id;
+ Type = type;
+ Name = name;
+ Sku = sku;
+ Location = location;
+ Identity = identity;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the display name of the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "properties.displayName")]
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets the ID of the policy definition or policy set
+ /// definition being assigned.
+ ///
+ [JsonProperty(PropertyName = "properties.policyDefinitionId")]
+ public string PolicyDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets the scope for the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "properties.scope")]
+ public string Scope { get; set; }
+
+ ///
+ /// Gets or sets the policy's excluded scopes.
+ ///
+ [JsonProperty(PropertyName = "properties.notScopes")]
+ public IList NotScopes { get; set; }
+
+ ///
+ /// Gets or sets required if a parameter is used in policy rule.
+ ///
+ [JsonProperty(PropertyName = "properties.parameters")]
+ public object Parameters { get; set; }
+
+ ///
+ /// Gets or sets this message will be part of response in case of
+ /// policy violation.
+ ///
+ [JsonProperty(PropertyName = "properties.description")]
+ public string Description { get; set; }
+
+ ///
+ /// Gets or sets the policy assignment metadata.
+ ///
+ [JsonProperty(PropertyName = "properties.metadata")]
+ public object Metadata { get; set; }
+
+ ///
+ /// Gets the ID of the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public string Id { get; private set; }
+
+ ///
+ /// Gets the type of the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; private set; }
+
+ ///
+ /// Gets the name of the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets or sets the policy sku. This property is optional, obsolete,
+ /// and will be ignored.
+ ///
+ [JsonProperty(PropertyName = "sku")]
+ public PolicySku Sku { get; set; }
+
+ ///
+ /// Gets or sets the location of the policy assignment. Only required
+ /// when utilizing managed identity.
+ ///
+ [JsonProperty(PropertyName = "location")]
+ public string Location { get; set; }
+
+ ///
+ /// Gets or sets the managed identity associated with the policy
+ /// assignment.
+ ///
+ [JsonProperty(PropertyName = "identity")]
+ public Identity Identity { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Sku != null)
+ {
+ Sku.Validate();
+ }
+ }
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicyDefinition.cs b/src/ResourceManager/Version2018_05_01/Models/PolicyDefinition.cs
new file mode 100644
index 0000000000..82a23f19a5
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicyDefinition.cs
@@ -0,0 +1,140 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The policy definition.
+ ///
+ [Rest.Serialization.JsonTransformation]
+ public partial class PolicyDefinition : IResource
+ {
+ ///
+ /// Initializes a new instance of the PolicyDefinition class.
+ ///
+ public PolicyDefinition()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyDefinition class.
+ ///
+ /// The type of policy definition. Possible
+ /// values are NotSpecified, BuiltIn, and Custom. Possible values
+ /// include: 'NotSpecified', 'BuiltIn', 'Custom'
+ /// The policy definition mode. Possible values are
+ /// NotSpecified, Indexed, and All. Possible values include:
+ /// 'NotSpecified', 'Indexed', 'All'
+ /// The display name of the policy
+ /// definition.
+ /// The policy definition
+ /// description.
+ /// The policy rule.
+ /// The policy definition metadata.
+ /// Required if a parameter is used in policy
+ /// rule.
+ /// The ID of the policy definition.
+ /// The name of the policy definition.
+ /// The type of the resource
+ /// (Microsoft.Authorization/policyDefinitions).
+ public PolicyDefinition(string policyType = default(string), string mode = default(string), string displayName = default(string), string description = default(string), object policyRule = default(object), object metadata = default(object), object parameters = default(object), string id = default(string), string name = default(string), string type = default(string))
+ {
+ PolicyType = policyType;
+ Mode = mode;
+ DisplayName = displayName;
+ Description = description;
+ PolicyRule = policyRule;
+ Metadata = metadata;
+ Parameters = parameters;
+ Id = id;
+ Name = name;
+ Type = type;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the type of policy definition. Possible values are
+ /// NotSpecified, BuiltIn, and Custom. Possible values include:
+ /// 'NotSpecified', 'BuiltIn', 'Custom'
+ ///
+ [JsonProperty(PropertyName = "properties.policyType")]
+ public string PolicyType { get; set; }
+
+ ///
+ /// Gets or sets the policy definition mode. Possible values are
+ /// NotSpecified, Indexed, and All. Possible values include:
+ /// 'NotSpecified', 'Indexed', 'All'
+ ///
+ [JsonProperty(PropertyName = "properties.mode")]
+ public string Mode { get; set; }
+
+ ///
+ /// Gets or sets the display name of the policy definition.
+ ///
+ [JsonProperty(PropertyName = "properties.displayName")]
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets the policy definition description.
+ ///
+ [JsonProperty(PropertyName = "properties.description")]
+ public string Description { get; set; }
+
+ ///
+ /// Gets or sets the policy rule.
+ ///
+ [JsonProperty(PropertyName = "properties.policyRule")]
+ public object PolicyRule { get; set; }
+
+ ///
+ /// Gets or sets the policy definition metadata.
+ ///
+ [JsonProperty(PropertyName = "properties.metadata")]
+ public object Metadata { get; set; }
+
+ ///
+ /// Gets or sets required if a parameter is used in policy rule.
+ ///
+ [JsonProperty(PropertyName = "properties.parameters")]
+ public object Parameters { get; set; }
+
+ ///
+ /// Gets the ID of the policy definition.
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public string Id { get; private set; }
+
+ ///
+ /// Gets the name of the policy definition.
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets the type of the resource
+ /// (Microsoft.Authorization/policyDefinitions).
+ ///
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; private set; }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicyDefinitionReference.cs b/src/ResourceManager/Version2018_05_01/Models/PolicyDefinitionReference.cs
new file mode 100644
index 0000000000..73085c1870
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicyDefinitionReference.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.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The policy definition reference.
+ ///
+ public partial class PolicyDefinitionReference
+ {
+ ///
+ /// Initializes a new instance of the PolicyDefinitionReference class.
+ ///
+ public PolicyDefinitionReference()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyDefinitionReference class.
+ ///
+ /// The ID of the policy definition or
+ /// policy set definition.
+ /// Required if a parameter is used in policy
+ /// rule.
+ public PolicyDefinitionReference(string policyDefinitionId = default(string), object parameters = default(object))
+ {
+ PolicyDefinitionId = policyDefinitionId;
+ Parameters = parameters;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the ID of the policy definition or policy set
+ /// definition.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionId")]
+ public string PolicyDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets required if a parameter is used in policy rule.
+ ///
+ [JsonProperty(PropertyName = "parameters")]
+ public object Parameters { get; set; }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicyMode.cs b/src/ResourceManager/Version2018_05_01/Models/PolicyMode.cs
new file mode 100644
index 0000000000..d440169a12
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicyMode.cs
@@ -0,0 +1,23 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+
+ ///
+ /// Defines values for PolicyMode.
+ ///
+ public static class PolicyMode
+ {
+ public const string NotSpecified = "NotSpecified";
+ public const string Indexed = "Indexed";
+ public const string All = "All";
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicySetDefinition.cs b/src/ResourceManager/Version2018_05_01/Models/PolicySetDefinition.cs
new file mode 100644
index 0000000000..a13cc63323
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicySetDefinition.cs
@@ -0,0 +1,145 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// The policy set definition.
+ ///
+ [Rest.Serialization.JsonTransformation]
+ public partial class PolicySetDefinition : IResource
+ {
+ ///
+ /// Initializes a new instance of the PolicySetDefinition class.
+ ///
+ public PolicySetDefinition()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicySetDefinition class.
+ ///
+ /// An array of policy definition
+ /// references.
+ /// The type of policy definition. Possible
+ /// values are NotSpecified, BuiltIn, and Custom. Possible values
+ /// include: 'NotSpecified', 'BuiltIn', 'Custom'
+ /// The display name of the policy set
+ /// definition.
+ /// The policy set definition
+ /// description.
+ /// The policy set definition metadata.
+ /// The policy set definition parameters that
+ /// can be used in policy definition references.
+ /// The ID of the policy set definition.
+ /// The name of the policy set definition.
+ /// The type of the resource
+ /// (Microsoft.Authorization/policySetDefinitions).
+ public PolicySetDefinition(IList policyDefinitions, string policyType = default(string), string displayName = default(string), string description = default(string), object metadata = default(object), object parameters = default(object), string id = default(string), string name = default(string), string type = default(string))
+ {
+ PolicyType = policyType;
+ DisplayName = displayName;
+ Description = description;
+ Metadata = metadata;
+ Parameters = parameters;
+ PolicyDefinitions = policyDefinitions;
+ Id = id;
+ Name = name;
+ Type = type;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the type of policy definition. Possible values are
+ /// NotSpecified, BuiltIn, and Custom. Possible values include:
+ /// 'NotSpecified', 'BuiltIn', 'Custom'
+ ///
+ [JsonProperty(PropertyName = "properties.policyType")]
+ public string PolicyType { get; set; }
+
+ ///
+ /// Gets or sets the display name of the policy set definition.
+ ///
+ [JsonProperty(PropertyName = "properties.displayName")]
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets the policy set definition description.
+ ///
+ [JsonProperty(PropertyName = "properties.description")]
+ public string Description { get; set; }
+
+ ///
+ /// Gets or sets the policy set definition metadata.
+ ///
+ [JsonProperty(PropertyName = "properties.metadata")]
+ public object Metadata { get; set; }
+
+ ///
+ /// Gets or sets the policy set definition parameters that can be used
+ /// in policy definition references.
+ ///
+ [JsonProperty(PropertyName = "properties.parameters")]
+ public object Parameters { get; set; }
+
+ ///
+ /// Gets or sets an array of policy definition references.
+ ///
+ [JsonProperty(PropertyName = "properties.policyDefinitions")]
+ public IList PolicyDefinitions { get; set; }
+
+ ///
+ /// Gets the ID of the policy set definition.
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public string Id { get; private set; }
+
+ ///
+ /// Gets the name of the policy set definition.
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets the type of the resource
+ /// (Microsoft.Authorization/policySetDefinitions).
+ ///
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; private set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (PolicyDefinitions == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "PolicyDefinitions");
+ }
+ }
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicySku.cs b/src/ResourceManager/Version2018_05_01/Models/PolicySku.cs
new file mode 100644
index 0000000000..3e0315ba81
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicySku.cs
@@ -0,0 +1,78 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+ using Microsoft.Rest;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The policy sku. This property is optional, obsolete, and will be
+ /// ignored.
+ ///
+ public partial class PolicySku
+ {
+ ///
+ /// Initializes a new instance of the PolicySku class.
+ ///
+ public PolicySku()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicySku class.
+ ///
+ /// The name of the policy sku. Possible values are
+ /// A0 and A1.
+ /// The policy sku tier. Possible values are Free
+ /// and Standard.
+ public PolicySku(string name, string tier = default(string))
+ {
+ Name = name;
+ Tier = tier;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the name of the policy sku. Possible values are A0 and
+ /// A1.
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ /// Gets or sets the policy sku tier. Possible values are Free and
+ /// Standard.
+ ///
+ [JsonProperty(PropertyName = "tier")]
+ public string Tier { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "Name");
+ }
+ }
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/Models/PolicyType.cs b/src/ResourceManager/Version2018_05_01/Models/PolicyType.cs
new file mode 100644
index 0000000000..5e3984e97d
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/Models/PolicyType.cs
@@ -0,0 +1,23 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models
+{
+
+ ///
+ /// Defines values for PolicyType.
+ ///
+ public static class PolicyType
+ {
+ public const string NotSpecified = "NotSpecified";
+ public const string BuiltIn = "BuiltIn";
+ public const string Custom = "Custom";
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/PolicyAssignmentsOperations.cs b/src/ResourceManager/Version2018_05_01/PolicyAssignmentsOperations.cs
new file mode 100644
index 0000000000..d00469fc10
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/PolicyAssignmentsOperations.cs
@@ -0,0 +1,2523 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Azure.OData;
+ 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;
+
+ ///
+ /// PolicyAssignmentsOperations operations.
+ ///
+ internal partial class PolicyAssignmentsOperations : IServiceOperations, IPolicyAssignmentsOperations
+ {
+ ///
+ /// Initializes a new instance of the PolicyAssignmentsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal PolicyAssignmentsOperations(PolicyClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the PolicyClient
+ ///
+ public PolicyClient Client { get; private set; }
+
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes a policy assignment, given its name and the scope it
+ /// was created in. The scope of a policy assignment is the part of its ID
+ /// preceding
+ /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to delete.
+ ///
+ ///
+ /// 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> DeleteWithHttpMessagesAsync(string scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (scope == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "scope");
+ }
+ if (policyAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("scope", scope);
+ tracingParameters.Add("policyAssignmentName", policyAssignmentName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString();
+ _url = _url.Replace("{scope}", scope);
+ _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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();
+ }
+ // 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 a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates a policy assignment with the given scope
+ /// and name. Policy assignments apply to all resources contained within their
+ /// scope. For example, when you assign a policy at resource group scope, that
+ /// policy applies to all resources in the group.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment.
+ ///
+ ///
+ /// Parameters for the policy assignment.
+ ///
+ ///
+ /// 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> CreateWithHttpMessagesAsync(string scope, string policyAssignmentName, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (scope == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "scope");
+ }
+ if (policyAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName");
+ }
+ if (parameters == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
+ }
+ if (parameters != null)
+ {
+ parameters.Validate();
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("scope", scope);
+ tracingParameters.Add("policyAssignmentName", policyAssignmentName);
+ tracingParameters.Add("parameters", parameters);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString();
+ _url = _url.Replace("{scope}", scope);
+ _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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 != 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 == 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;
+ }
+
+ ///
+ /// Retrieves a policy assignment.
+ ///
+ ///
+ /// This operation retrieves a single policy assignment, given its name and the
+ /// scope it was created at.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to get.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (scope == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "scope");
+ }
+ if (policyAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("scope", scope);
+ tracingParameters.Add("policyAssignmentName", policyAssignmentName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString();
+ _url = _url.Replace("{scope}", scope);
+ _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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;
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given resource group in the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource group, including those that apply directly or apply from
+ /// containing scopes, as well as any applied to resources contained within the
+ /// resource group. If $filter=atScope() is provided, the returned list
+ /// includes all policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy assignments
+ /// that apply to the resource group and assign the policy definition whose id
+ /// is {value}.
+ ///
+ ///
+ /// The name of the resource group that contains policy assignments.
+ ///
+ ///
+ /// The filter to apply on the operation. Valid values for $filter are:
+ /// 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not
+ /// provided, no filtering is performed.
+ ///
+ ///
+ /// 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 resourceGroupName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (resourceGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
+ }
+ if (resourceGroupName != null)
+ {
+ if (resourceGroupName.Length > 90)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90);
+ }
+ if (resourceGroupName.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1);
+ }
+ if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$");
+ }
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("resourceGroupName", resourceGroupName);
+ 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.Authorization/policyAssignments").ToString();
+ _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", filter));
+ }
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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;
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the specified resource in the given resource group and subscription that
+ /// match the optional given $filter. Valid values for $filter are: 'atScope()'
+ /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource, including those that apply directly or from all containing
+ /// scopes, as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the resource, which is everything in the
+ /// unfiltered list except those applied to resources contained within the
+ /// resource. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the resource
+ /// and assign the policy definition whose id is {value}. Three parameters plus
+ /// the resource name are used to identify a specific resource. If the resource
+ /// is not part of a parent resource (the more common case), the parent
+ /// resource path should not be provided (or provided as ''). For example a web
+ /// app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
+ /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} ==
+ /// 'MyWebApp'). If the resource is part of a parent resource, then all
+ /// parameters should be provided. For example a virtual machine DNS name could
+ /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType}
+ /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient
+ /// alternative to providing the namespace and type name separately is to
+ /// provide both in the {resourceType} parameter, format:
+ /// ({resourceProviderNamespace} == '', {parentResourcePath} == '',
+ /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// The name of the resource group containing the resource.
+ ///
+ ///
+ /// The namespace of the resource provider. For example, the namespace of a
+ /// virtual machine is Microsoft.Compute (from
+ /// Microsoft.Compute/virtualMachines)
+ ///
+ ///
+ /// The parent resource path. Use empty string if there is none.
+ ///
+ ///
+ /// The resource type name. For example the type name of a web app is 'sites'
+ /// (from Microsoft.Web/sites).
+ ///
+ ///
+ /// The name of the resource.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListForResourceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (resourceGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
+ }
+ if (resourceGroupName != null)
+ {
+ if (resourceGroupName.Length > 90)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90);
+ }
+ if (resourceGroupName.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1);
+ }
+ if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$");
+ }
+ }
+ if (resourceProviderNamespace == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace");
+ }
+ if (parentResourcePath == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath");
+ }
+ if (resourceType == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceType");
+ }
+ if (resourceName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("odataQuery", odataQuery);
+ tracingParameters.Add("resourceGroupName", resourceGroupName);
+ tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace);
+ tracingParameters.Add("parentResourcePath", parentResourcePath);
+ tracingParameters.Add("resourceType", resourceType);
+ tracingParameters.Add("resourceName", resourceName);
+ 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments").ToString();
+ _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
+ _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace));
+ _url = _url.Replace("{parentResourcePath}", parentResourcePath);
+ _url = _url.Replace("{resourceType}", resourceType);
+ _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (odataQuery != null)
+ {
+ var _odataFilter = odataQuery.ToString();
+ if (!string.IsNullOrEmpty(_odataFilter))
+ {
+ _queryParameters.Add(_odataFilter);
+ }
+ }
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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;
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given subscription that match the optional given $filter. Valid values
+ /// for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
+ /// $filter is not provided, the unfiltered list includes all policy
+ /// assignments associated with the subscription, including those that apply
+ /// directly or from management groups that contain the given subscription, as
+ /// well as any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the subscription, which is everything in the
+ /// unfiltered list except those applied to objects contained within the
+ /// subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the
+ /// subscription and assign the policy definition whose id is {value}.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("odataQuery", odataQuery);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments").ToString();
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (odataQuery != null)
+ {
+ var _odataFilter = odataQuery.ToString();
+ if (!string.IsNullOrEmpty(_odataFilter))
+ {
+ _queryParameters.Add(_odataFilter);
+ }
+ }
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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 a policy assignment.
+ ///
+ ///
+ /// This operation deletes the policy with the given ID. Policy assignment IDs
+ /// have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid formats for {scope} are:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'
+ /// (management group), '/subscriptions/{subscriptionId}' (subscription),
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
+ /// (resource group), or
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ /// (resource).
+ ///
+ ///
+ /// The ID of the policy assignment to delete. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// 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> DeleteByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyAssignmentId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyAssignmentId", policyAssignmentId);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "DeleteById", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString();
+ _url = _url.Replace("{policyAssignmentId}", policyAssignmentId);
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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();
+ }
+ // 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 a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates the policy assignment with the given ID.
+ /// Policy assignments made on a scope apply to all resources contained in that
+ /// scope. For example, when you assign a policy to a resource group that
+ /// policy applies to all resources in the group. Policy assignment IDs have
+ /// this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The ID of the policy assignment to create. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// Parameters for policy assignment.
+ ///
+ ///
+ /// 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> CreateByIdWithHttpMessagesAsync(string policyAssignmentId, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyAssignmentId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId");
+ }
+ if (parameters == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
+ }
+ if (parameters != null)
+ {
+ parameters.Validate();
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyAssignmentId", policyAssignmentId);
+ tracingParameters.Add("parameters", parameters);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CreateById", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString();
+ _url = _url.Replace("{policyAssignmentId}", policyAssignmentId);
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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 != 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 == 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;
+ }
+
+ ///
+ /// Retrieves the policy assignment with the given ID.
+ ///
+ ///
+ /// The operation retrieves the policy assignment with the given ID. Policy
+ /// assignment IDs have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The ID of the policy assignment to get. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// 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> GetByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyAssignmentId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyAssignmentId", policyAssignmentId);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetById", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString();
+ _url = _url.Replace("{policyAssignmentId}", policyAssignmentId);
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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;
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given resource group in the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource group, including those that apply directly or apply from
+ /// containing scopes, as well as any applied to resources contained within the
+ /// resource group. If $filter=atScope() is provided, the returned list
+ /// includes all policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy assignments
+ /// that apply to the resource group and assign the policy definition whose id
+ /// is {value}.
+ ///
+ ///
+ /// 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;
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the specified resource in the given resource group and subscription that
+ /// match the optional given $filter. Valid values for $filter are: 'atScope()'
+ /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource, including those that apply directly or from all containing
+ /// scopes, as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the resource, which is everything in the
+ /// unfiltered list except those applied to resources contained within the
+ /// resource. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the resource
+ /// and assign the policy definition whose id is {value}. Three parameters plus
+ /// the resource name are used to identify a specific resource. If the resource
+ /// is not part of a parent resource (the more common case), the parent
+ /// resource path should not be provided (or provided as ''). For example a web
+ /// app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
+ /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} ==
+ /// 'MyWebApp'). If the resource is part of a parent resource, then all
+ /// parameters should be provided. For example a virtual machine DNS name could
+ /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType}
+ /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient
+ /// alternative to providing the namespace and type name separately is to
+ /// provide both in the {resourceType} parameter, format:
+ /// ({resourceProviderNamespace} == '', {parentResourcePath} == '',
+ /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// 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;
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given subscription that match the optional given $filter. Valid values
+ /// for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
+ /// $filter is not provided, the unfiltered list includes all policy
+ /// assignments associated with the subscription, including those that apply
+ /// directly or from management groups that contain the given subscription, as
+ /// well as any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the subscription, which is everything in the
+ /// unfiltered list except those applied to objects contained within the
+ /// subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the
+ /// subscription and assign the policy definition whose id is {value}.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new 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/src/ResourceManager/Version2018_05_01/PolicyAssignmentsOperationsExtensions.cs b/src/ResourceManager/Version2018_05_01/PolicyAssignmentsOperationsExtensions.cs
new file mode 100644
index 0000000000..88c3244b23
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/PolicyAssignmentsOperationsExtensions.cs
@@ -0,0 +1,908 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Azure.OData;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for PolicyAssignmentsOperations.
+ ///
+ public static partial class PolicyAssignmentsOperationsExtensions
+ {
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes a policy assignment, given its name and the scope it
+ /// was created in. The scope of a policy assignment is the part of its ID
+ /// preceding
+ /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to delete.
+ ///
+ public static PolicyAssignment Delete(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName)
+ {
+ return operations.DeleteAsync(scope, policyAssignmentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes a policy assignment, given its name and the scope it
+ /// was created in. The scope of a policy assignment is the part of its ID
+ /// preceding
+ /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to delete.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.DeleteWithHttpMessagesAsync(scope, policyAssignmentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Creates or updates a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates a policy assignment with the given scope
+ /// and name. Policy assignments apply to all resources contained within their
+ /// scope. For example, when you assign a policy at resource group scope, that
+ /// policy applies to all resources in the group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment.
+ ///
+ ///
+ /// Parameters for the policy assignment.
+ ///
+ public static PolicyAssignment Create(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, PolicyAssignment parameters)
+ {
+ return operations.CreateAsync(scope, policyAssignmentName, parameters).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Creates or updates a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates a policy assignment with the given scope
+ /// and name. Policy assignments apply to all resources contained within their
+ /// scope. For example, when you assign a policy at resource group scope, that
+ /// policy applies to all resources in the group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment.
+ ///
+ ///
+ /// Parameters for the policy assignment.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CreateAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, PolicyAssignment parameters, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CreateWithHttpMessagesAsync(scope, policyAssignmentName, parameters, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves a policy assignment.
+ ///
+ ///
+ /// This operation retrieves a single policy assignment, given its name and the
+ /// scope it was created at.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to get.
+ ///
+ public static PolicyAssignment Get(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName)
+ {
+ return operations.GetAsync(scope, policyAssignmentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves a policy assignment.
+ ///
+ ///
+ /// This operation retrieves a single policy assignment, given its name and the
+ /// scope it was created at.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The scope of the policy assignment. Valid scopes are: management group
+ /// (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ ///
+ ///
+ /// The name of the policy assignment to get.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(scope, policyAssignmentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given resource group in the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource group, including those that apply directly or apply from
+ /// containing scopes, as well as any applied to resources contained within the
+ /// resource group. If $filter=atScope() is provided, the returned list
+ /// includes all policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy assignments
+ /// that apply to the resource group and assign the policy definition whose id
+ /// is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group that contains policy assignments.
+ ///
+ ///
+ /// The filter to apply on the operation. Valid values for $filter are:
+ /// 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not
+ /// provided, no filtering is performed.
+ ///
+ public static IPage ListForResourceGroup(this IPolicyAssignmentsOperations operations, string resourceGroupName, string filter = default(string))
+ {
+ return operations.ListForResourceGroupAsync(resourceGroupName, filter).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given resource group in the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource group, including those that apply directly or apply from
+ /// containing scopes, as well as any applied to resources contained within the
+ /// resource group. If $filter=atScope() is provided, the returned list
+ /// includes all policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy assignments
+ /// that apply to the resource group and assign the policy definition whose id
+ /// is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group that contains policy assignments.
+ ///
+ ///
+ /// The filter to apply on the operation. Valid values for $filter are:
+ /// 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not
+ /// provided, no filtering is performed.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListForResourceGroupAsync(this IPolicyAssignmentsOperations operations, string resourceGroupName, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListForResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the specified resource in the given resource group and subscription that
+ /// match the optional given $filter. Valid values for $filter are: 'atScope()'
+ /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource, including those that apply directly or from all containing
+ /// scopes, as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the resource, which is everything in the
+ /// unfiltered list except those applied to resources contained within the
+ /// resource. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the resource
+ /// and assign the policy definition whose id is {value}. Three parameters plus
+ /// the resource name are used to identify a specific resource. If the resource
+ /// is not part of a parent resource (the more common case), the parent
+ /// resource path should not be provided (or provided as ''). For example a web
+ /// app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
+ /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} ==
+ /// 'MyWebApp'). If the resource is part of a parent resource, then all
+ /// parameters should be provided. For example a virtual machine DNS name could
+ /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType}
+ /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient
+ /// alternative to providing the namespace and type name separately is to
+ /// provide both in the {resourceType} parameter, format:
+ /// ({resourceProviderNamespace} == '', {parentResourcePath} == '',
+ /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group containing the resource.
+ ///
+ ///
+ /// The namespace of the resource provider. For example, the namespace of a
+ /// virtual machine is Microsoft.Compute (from
+ /// Microsoft.Compute/virtualMachines)
+ ///
+ ///
+ /// The parent resource path. Use empty string if there is none.
+ ///
+ ///
+ /// The resource type name. For example the type name of a web app is 'sites'
+ /// (from Microsoft.Web/sites).
+ ///
+ ///
+ /// The name of the resource.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ public static IPage ListForResource(this IPolicyAssignmentsOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery))
+ {
+ return operations.ListForResourceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, odataQuery).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the specified resource in the given resource group and subscription that
+ /// match the optional given $filter. Valid values for $filter are: 'atScope()'
+ /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource, including those that apply directly or from all containing
+ /// scopes, as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the resource, which is everything in the
+ /// unfiltered list except those applied to resources contained within the
+ /// resource. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the resource
+ /// and assign the policy definition whose id is {value}. Three parameters plus
+ /// the resource name are used to identify a specific resource. If the resource
+ /// is not part of a parent resource (the more common case), the parent
+ /// resource path should not be provided (or provided as ''). For example a web
+ /// app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
+ /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} ==
+ /// 'MyWebApp'). If the resource is part of a parent resource, then all
+ /// parameters should be provided. For example a virtual machine DNS name could
+ /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType}
+ /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient
+ /// alternative to providing the namespace and type name separately is to
+ /// provide both in the {resourceType} parameter, format:
+ /// ({resourceProviderNamespace} == '', {parentResourcePath} == '',
+ /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group containing the resource.
+ ///
+ ///
+ /// The namespace of the resource provider. For example, the namespace of a
+ /// virtual machine is Microsoft.Compute (from
+ /// Microsoft.Compute/virtualMachines)
+ ///
+ ///
+ /// The parent resource path. Use empty string if there is none.
+ ///
+ ///
+ /// The resource type name. For example the type name of a web app is 'sites'
+ /// (from Microsoft.Web/sites).
+ ///
+ ///
+ /// The name of the resource.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListForResourceAsync(this IPolicyAssignmentsOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListForResourceWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, odataQuery, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given subscription that match the optional given $filter. Valid values
+ /// for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
+ /// $filter is not provided, the unfiltered list includes all policy
+ /// assignments associated with the subscription, including those that apply
+ /// directly or from management groups that contain the given subscription, as
+ /// well as any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the subscription, which is everything in the
+ /// unfiltered list except those applied to objects contained within the
+ /// subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the
+ /// subscription and assign the policy definition whose id is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ public static IPage List(this IPolicyAssignmentsOperations operations, ODataQuery odataQuery = default(ODataQuery))
+ {
+ return operations.ListAsync(odataQuery).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given subscription that match the optional given $filter. Valid values
+ /// for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
+ /// $filter is not provided, the unfiltered list includes all policy
+ /// assignments associated with the subscription, including those that apply
+ /// directly or from management groups that contain the given subscription, as
+ /// well as any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the subscription, which is everything in the
+ /// unfiltered list except those applied to objects contained within the
+ /// subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the
+ /// subscription and assign the policy definition whose id is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAsync(this IPolicyAssignmentsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes the policy with the given ID. Policy assignment IDs
+ /// have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid formats for {scope} are:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'
+ /// (management group), '/subscriptions/{subscriptionId}' (subscription),
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
+ /// (resource group), or
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ /// (resource).
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The ID of the policy assignment to delete. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ public static PolicyAssignment DeleteById(this IPolicyAssignmentsOperations operations, string policyAssignmentId)
+ {
+ return operations.DeleteByIdAsync(policyAssignmentId).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Deletes a policy assignment.
+ ///
+ ///
+ /// This operation deletes the policy with the given ID. Policy assignment IDs
+ /// have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid formats for {scope} are:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'
+ /// (management group), '/subscriptions/{subscriptionId}' (subscription),
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
+ /// (resource group), or
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
+ /// (resource).
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The ID of the policy assignment to delete. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.DeleteByIdWithHttpMessagesAsync(policyAssignmentId, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Creates or updates a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates the policy assignment with the given ID.
+ /// Policy assignments made on a scope apply to all resources contained in that
+ /// scope. For example, when you assign a policy to a resource group that
+ /// policy applies to all resources in the group. Policy assignment IDs have
+ /// this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The ID of the policy assignment to create. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// Parameters for policy assignment.
+ ///
+ public static PolicyAssignment CreateById(this IPolicyAssignmentsOperations operations, string policyAssignmentId, PolicyAssignment parameters)
+ {
+ return operations.CreateByIdAsync(policyAssignmentId, parameters).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Creates or updates a policy assignment.
+ ///
+ ///
+ /// This operation creates or updates the policy assignment with the given ID.
+ /// Policy assignments made on a scope apply to all resources contained in that
+ /// scope. For example, when you assign a policy to a resource group that
+ /// policy applies to all resources in the group. Policy assignment IDs have
+ /// this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The ID of the policy assignment to create. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// Parameters for policy assignment.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CreateByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, PolicyAssignment parameters, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CreateByIdWithHttpMessagesAsync(policyAssignmentId, parameters, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves the policy assignment with the given ID.
+ ///
+ ///
+ /// The operation retrieves the policy assignment with the given ID. Policy
+ /// assignment IDs have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The ID of the policy assignment to get. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ public static PolicyAssignment GetById(this IPolicyAssignmentsOperations operations, string policyAssignmentId)
+ {
+ return operations.GetByIdAsync(policyAssignmentId).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves the policy assignment with the given ID.
+ ///
+ ///
+ /// The operation retrieves the policy assignment with the given ID. Policy
+ /// assignment IDs have this format:
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ /// Valid scopes are: management group (format:
+ /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
+ /// subscription (format: '/subscriptions/{subscriptionId}'), resource group
+ /// (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
+ /// resource (format:
+ /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The ID of the policy assignment to get. Use the format
+ /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetByIdWithHttpMessagesAsync(policyAssignmentId, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given resource group in the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource group, including those that apply directly or apply from
+ /// containing scopes, as well as any applied to resources contained within the
+ /// resource group. If $filter=atScope() is provided, the returned list
+ /// includes all policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy assignments
+ /// that apply to the resource group and assign the policy definition whose id
+ /// is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ public static IPage ListForResourceGroupNext(this IPolicyAssignmentsOperations operations, string nextPageLink)
+ {
+ return operations.ListForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource group.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given resource group in the given subscription that match the optional
+ /// given $filter. Valid values for $filter are: 'atScope()' or
+ /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource group, including those that apply directly or apply from
+ /// containing scopes, as well as any applied to resources contained within the
+ /// resource group. If $filter=atScope() is provided, the returned list
+ /// includes all policy assignments that apply to the resource group, which is
+ /// everything in the unfiltered list except those applied to resources
+ /// contained within the resource group. If $filter=policyDefinitionId eq
+ /// '{value}' is provided, the returned list includes only policy assignments
+ /// that apply to the resource group and assign the policy definition whose id
+ /// is {value}.
+ ///
+ ///
+ /// 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 IPolicyAssignmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the specified resource in the given resource group and subscription that
+ /// match the optional given $filter. Valid values for $filter are: 'atScope()'
+ /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource, including those that apply directly or from all containing
+ /// scopes, as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the resource, which is everything in the
+ /// unfiltered list except those applied to resources contained within the
+ /// resource. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the resource
+ /// and assign the policy definition whose id is {value}. Three parameters plus
+ /// the resource name are used to identify a specific resource. If the resource
+ /// is not part of a parent resource (the more common case), the parent
+ /// resource path should not be provided (or provided as ''). For example a web
+ /// app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
+ /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} ==
+ /// 'MyWebApp'). If the resource is part of a parent resource, then all
+ /// parameters should be provided. For example a virtual machine DNS name could
+ /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType}
+ /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient
+ /// alternative to providing the namespace and type name separately is to
+ /// provide both in the {resourceType} parameter, format:
+ /// ({resourceProviderNamespace} == '', {parentResourcePath} == '',
+ /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ public static IPage ListForResourceNext(this IPolicyAssignmentsOperations operations, string nextPageLink)
+ {
+ return operations.ListForResourceNextAsync(nextPageLink).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a resource.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the specified resource in the given resource group and subscription that
+ /// match the optional given $filter. Valid values for $filter are: 'atScope()'
+ /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
+ /// unfiltered list includes all policy assignments associated with the
+ /// resource, including those that apply directly or from all containing
+ /// scopes, as well as any applied to resources contained within the resource.
+ /// If $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the resource, which is everything in the
+ /// unfiltered list except those applied to resources contained within the
+ /// resource. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the resource
+ /// and assign the policy definition whose id is {value}. Three parameters plus
+ /// the resource name are used to identify a specific resource. If the resource
+ /// is not part of a parent resource (the more common case), the parent
+ /// resource path should not be provided (or provided as ''). For example a web
+ /// app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web',
+ /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} ==
+ /// 'MyWebApp'). If the resource is part of a parent resource, then all
+ /// parameters should be provided. For example a virtual machine DNS name could
+ /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute',
+ /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType}
+ /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient
+ /// alternative to providing the namespace and type name separately is to
+ /// provide both in the {resourceType} parameter, format:
+ /// ({resourceProviderNamespace} == '', {parentResourcePath} == '',
+ /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
+ ///
+ ///
+ /// 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 IPolicyAssignmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given subscription that match the optional given $filter. Valid values
+ /// for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
+ /// $filter is not provided, the unfiltered list includes all policy
+ /// assignments associated with the subscription, including those that apply
+ /// directly or from management groups that contain the given subscription, as
+ /// well as any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the subscription, which is everything in the
+ /// unfiltered list except those applied to objects contained within the
+ /// subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the
+ /// subscription and assign the policy definition whose id is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ public static IPage ListNext(this IPolicyAssignmentsOperations operations, string nextPageLink)
+ {
+ return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Retrieves all policy assignments that apply to a subscription.
+ ///
+ ///
+ /// This operation retrieves the list of all policy assignments associated with
+ /// the given subscription that match the optional given $filter. Valid values
+ /// for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
+ /// $filter is not provided, the unfiltered list includes all policy
+ /// assignments associated with the subscription, including those that apply
+ /// directly or from management groups that contain the given subscription, as
+ /// well as any applied to objects contained within the subscription. If
+ /// $filter=atScope() is provided, the returned list includes all policy
+ /// assignments that apply to the subscription, which is everything in the
+ /// unfiltered list except those applied to objects contained within the
+ /// subscription. If $filter=policyDefinitionId eq '{value}' is provided, the
+ /// returned list includes only policy assignments that apply to the
+ /// subscription and assign the policy definition whose id is {value}.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListNextAsync(this IPolicyAssignmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/PolicyClient.cs b/src/ResourceManager/Version2018_05_01/PolicyClient.cs
new file mode 100644
index 0000000000..c7fd09f291
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/PolicyClient.cs
@@ -0,0 +1,373 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+
+ ///
+ /// To manage and control access to your resources, you can define
+ /// customized policies and assign them at a scope.
+ ///
+ public partial class PolicyClient : ServiceClient, IPolicyClient, IAzureClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ public System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ public JsonSerializerSettings SerializationSettings { get; private set; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ public JsonSerializerSettings DeserializationSettings { get; private set; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ public ServiceClientCredentials Credentials { get; private set; }
+
+ ///
+ /// The ID of the target subscription.
+ ///
+ public string SubscriptionId { get; set; }
+
+ ///
+ /// The API version to use for the operation.
+ ///
+ public string ApiVersion { get; private set; }
+
+ ///
+ /// The preferred language for the response.
+ ///
+ public string AcceptLanguage { get; set; }
+
+ ///
+ /// The retry timeout in seconds for Long Running Operations. Default value is
+ /// 30.
+ ///
+ public int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// Whether a unique x-ms-client-request-id should be generated. When set to
+ /// true a unique x-ms-client-request-id value is generated and included in
+ /// each request. Default is true.
+ ///
+ public bool? GenerateClientRequestId { get; set; }
+
+ ///
+ /// Gets the IPolicyAssignmentsOperations.
+ ///
+ public virtual IPolicyAssignmentsOperations PolicyAssignments { get; private set; }
+
+ ///
+ /// Gets the IPolicyDefinitionsOperations.
+ ///
+ public virtual IPolicyDefinitionsOperations PolicyDefinitions { get; private set; }
+
+ ///
+ /// Gets the IPolicySetDefinitionsOperations.
+ ///
+ public virtual IPolicySetDefinitionsOperations PolicySetDefinitions { get; private set; }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling PolicyClient.Dispose(). False: will not dispose provided httpClient
+ protected PolicyClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected PolicyClient(params DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected PolicyClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ protected PolicyClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ protected PolicyClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public PolicyClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling PolicyClient.Dispose(). False: will not dispose provided httpClient
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public PolicyClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public PolicyClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public PolicyClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ BaseUri = baseUri;
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public PolicyClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ BaseUri = baseUri;
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ PolicyAssignments = new PolicyAssignmentsOperations(this);
+ PolicyDefinitions = new PolicyDefinitionsOperations(this);
+ PolicySetDefinitions = new PolicySetDefinitionsOperations(this);
+ BaseUri = new System.Uri("https://management.azure.com");
+ ApiVersion = "2018-05-01";
+ AcceptLanguage = "en-US";
+ LongRunningOperationRetryTimeout = 30;
+ GenerateClientRequestId = true;
+ SerializationSettings = new JsonSerializerSettings
+ {
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ SerializationSettings.Converters.Add(new TransformationJsonConverter());
+ DeserializationSettings = new JsonSerializerSettings
+ {
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ CustomInitialize();
+ DeserializationSettings.Converters.Add(new TransformationJsonConverter());
+ DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
+ }
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/PolicyDefinitionsOperations.cs b/src/ResourceManager/Version2018_05_01/PolicyDefinitionsOperations.cs
new file mode 100644
index 0000000000..8f46f58222
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/PolicyDefinitionsOperations.cs
@@ -0,0 +1,2458 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ 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;
+
+ ///
+ /// PolicyDefinitionsOperations operations.
+ ///
+ internal partial class PolicyDefinitionsOperations : IServiceOperations, IPolicyDefinitionsOperations
+ {
+ ///
+ /// Initializes a new instance of the PolicyDefinitionsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal PolicyDefinitionsOperations(PolicyClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the PolicyClient
+ ///
+ public PolicyClient Client { get; private set; }
+
+ ///
+ /// Creates or updates a policy definition in a subscription.
+ ///
+ ///
+ /// This operation creates or updates a policy definition in the given
+ /// subscription with the given name.
+ ///
+ ///
+ /// The name of the policy definition to create.
+ ///
+ ///
+ /// The policy definition properties.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CreateOrUpdateWithHttpMessagesAsync(string policyDefinitionName, PolicyDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName");
+ }
+ if (parameters == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyDefinitionName", policyDefinitionName);
+ tracingParameters.Add("parameters", parameters);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString();
+ _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.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 != 201)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 201)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Deletes a policy definition in a subscription.
+ ///
+ ///
+ /// This operation deletes the policy definition in the given subscription with
+ /// the given name.
+ ///
+ ///
+ /// The name of the policy definition to delete.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task DeleteWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyDefinitionName", policyDefinitionName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString();
+ _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 204)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Retrieves a policy definition in a subscription.
+ ///
+ ///
+ /// This operation retrieves the policy definition in the given subscription
+ /// with the given name.
+ ///
+ ///
+ /// The name of the policy definition to get.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyDefinitionName", policyDefinitionName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString();
+ _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Retrieves a built-in policy definition.
+ ///
+ ///
+ /// This operation retrieves the built-in policy definition with the given
+ /// name.
+ ///
+ ///
+ /// The name of the built-in policy definition to get.
+ ///
+ ///
+ /// 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> GetBuiltInWithHttpMessagesAsync(string policyDefinitionName, Dictionary