diff --git a/Documentation/README.md b/Documentation/README.md
index 145b5274456e..5a385b273a23 100644
--- a/Documentation/README.md
+++ b/Documentation/README.md
@@ -47,6 +47,7 @@ These SDKs depend on Microsoft.Rest.ClientRuntime.Azure
| Machine Learning Compute | Microsoft.Azure.Management.MachineLearningCompute |
| Network | Microsoft.Azure.Management.Network |
| NotificationHubs | Microsoft.Azure.Management.NotificationHubs |
+| Policy Insights | Microsoft.Azure.Management.PolicyInsights |
| PowerBI | Microsoft.Azure.Management.PowerBIEmbedded |
| Redis Cache | Microsoft.Azure.Management.Redis |
| Resource Manager (ARM) | Microsoft.Azure.Management.ResourceManager |
diff --git a/Documentation/sdk-for-net-packages.md b/Documentation/sdk-for-net-packages.md
index b6c395b6a50f..b19a9fa6d798 100644
--- a/Documentation/sdk-for-net-packages.md
+++ b/Documentation/sdk-for-net-packages.md
@@ -34,6 +34,7 @@ Below are the packages maintained in this repository.
| Monitor | `Microsoft.Azure.Management.Monitor` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.Monitor) |
| Network | `Microsoft.Azure.Management.Network` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.Network) |
| Notification Hubs | `Microsoft.Azure.Management.NotificationHubs` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.NotificationHubs) |
+| Policy Insights | `Microsoft.Azure.Management.PolicyInsights` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.PolicyInsights) |
| Operational Insights | `Microsoft.Azure.Management.OperationalInsights` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.OperationalInsights) |
| Power BI Embedded | `Microsoft.Azure.Management.PowerBIEmbedded` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.PowerBIEmbedded) |
| RecoveryServices | `Microsoft.Azure.Management.RecoveryServices` | [](https://www.nuget.org/packages/Microsoft.Azure.Management.RecoveryServices) |
diff --git a/src/SDKs/PolicyInsights/Management/AzSdk.RP.props b/src/SDKs/PolicyInsights/Management/AzSdk.RP.props
new file mode 100644
index 000000000000..36c3a93d2208
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/AzSdk.RP.props
@@ -0,0 +1,7 @@
+
+
+
+ PolicyInsights_2017-12-12-preview;
+ $(PackageTags);$(CommonTags);$(AzureApiTag);
+
+
\ No newline at end of file
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IOperations.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IOperations.cs
new file mode 100644
index 000000000000..f1f244053b19
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IOperations.cs
@@ -0,0 +1,46 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Operations operations.
+ ///
+ public partial interface IOperations
+ {
+ ///
+ /// Lists available operations.
+ ///
+ ///
+ /// 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));
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyEventsOperations.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyEventsOperations.cs
new file mode 100644
index 000000000000..e90994caa876
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyEventsOperations.cs
@@ -0,0 +1,270 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicyEventsOperations operations.
+ ///
+ public partial interface IPolicyEventsOperations
+ {
+ ///
+ /// Queries policy events for the resources under the management group.
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the resources under the subscription.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the resources under the resource group.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the resource.
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the subscription level policy set
+ /// definition.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy set definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the subscription level policy definition.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the subscription level policy assignment.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy events for the resource group level policy
+ /// assignment.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Gets OData metadata XML document.
+ ///
+ ///
+ /// A valid scope, i.e. management group, subscription, resource group,
+ /// or resource ID. Scope used has no effect on metadata returned.
+ ///
+ ///
+ /// 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> GetMetadataWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyInsightsClient.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyInsightsClient.cs
new file mode 100644
index 000000000000..5393daf84faf
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyInsightsClient.cs
@@ -0,0 +1,81 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+
+ ///
+ ///
+ public partial interface IPolicyInsightsClient : 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; }
+
+ ///
+ /// API version to use with the client requests.
+ ///
+ string ApiVersion { get; }
+
+ ///
+ /// Gets or sets the preferred language for the response.
+ ///
+ string AcceptLanguage { get; set; }
+
+ ///
+ /// Gets or sets the retry timeout in seconds for Long Running
+ /// Operations. Default value is 30.
+ ///
+ int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// 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 IPolicyEventsOperations.
+ ///
+ IPolicyEventsOperations PolicyEvents { get; }
+
+ ///
+ /// Gets the IPolicyStatesOperations.
+ ///
+ IPolicyStatesOperations PolicyStates { get; }
+
+ ///
+ /// Gets the IOperations.
+ ///
+ IOperations Operations { get; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyStatesOperations.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyStatesOperations.cs
new file mode 100644
index 000000000000..aefa46d6027f
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/IPolicyStatesOperations.cs
@@ -0,0 +1,542 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicyStatesOperations operations.
+ ///
+ public partial interface IPolicyStatesOperations
+ {
+ ///
+ /// Queries policy states for the resources under the management group.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the resources under the management
+ /// group.
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the resources under the subscription.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the resources under the subscription.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the resources under the resource group.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the resources under the resource
+ /// group.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the resource.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForResourceWithHttpMessagesAsync(string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the resource.
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the subscription level policy set
+ /// definition.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy set definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the subscription level policy set
+ /// definition.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy set definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForPolicySetDefinitionWithHttpMessagesAsync(string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the subscription level policy definition.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the subscription level policy
+ /// definition.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForPolicyDefinitionWithHttpMessagesAsync(string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the subscription level policy assignment.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the subscription level policy
+ /// assignment.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Queries policy states for the resource group level policy
+ /// assignment.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given
+ /// time range, 'latest' represents the latest policy state(s), whereas
+ /// 'default' represents all policy state(s). Possible values include:
+ /// 'default', 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Summarizes policy states for the resource group level policy
+ /// assignment.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> SummarizeForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Gets OData metadata XML document.
+ ///
+ ///
+ /// A valid scope, i.e. management group, subscription, resource group,
+ /// or resource ID. Scope used has no effect on metadata returned.
+ ///
+ ///
+ /// 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> GetMetadataWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/Operation.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/Operation.cs
new file mode 100644
index 000000000000..47244f78f8f6
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/Operation.cs
@@ -0,0 +1,60 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Operation definition.
+ ///
+ public partial class Operation
+ {
+ ///
+ /// Initializes a new instance of the Operation class.
+ ///
+ public Operation()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the Operation class.
+ ///
+ /// Operation name.
+ /// Display metadata associated with the
+ /// operation.
+ public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay))
+ {
+ Name = name;
+ Display = display;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets operation name.
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ /// Gets or sets display metadata associated with the operation.
+ ///
+ [JsonProperty(PropertyName = "display")]
+ public OperationDisplay Display { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/OperationDisplay.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/OperationDisplay.cs
new file mode 100644
index 000000000000..f3178909aafa
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/OperationDisplay.cs
@@ -0,0 +1,76 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Display metadata associated with the operation.
+ ///
+ public partial class OperationDisplay
+ {
+ ///
+ /// Initializes a new instance of the OperationDisplay class.
+ ///
+ public OperationDisplay()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the OperationDisplay class.
+ ///
+ /// Resource provider name.
+ /// Resource name on which the operation is
+ /// performed.
+ /// Operation name.
+ /// Operation description.
+ public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string))
+ {
+ Provider = provider;
+ Resource = resource;
+ Operation = operation;
+ Description = description;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets resource provider name.
+ ///
+ [JsonProperty(PropertyName = "provider")]
+ public string Provider { get; set; }
+
+ ///
+ /// Gets or sets resource name on which the operation is performed.
+ ///
+ [JsonProperty(PropertyName = "resource")]
+ public string Resource { get; set; }
+
+ ///
+ /// Gets or sets operation name.
+ ///
+ [JsonProperty(PropertyName = "operation")]
+ public string Operation { get; set; }
+
+ ///
+ /// Gets or sets operation description.
+ ///
+ [JsonProperty(PropertyName = "description")]
+ public string Description { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/OperationsListResults.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/OperationsListResults.cs
new file mode 100644
index 000000000000..6428bd739c3b
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/OperationsListResults.cs
@@ -0,0 +1,77 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Microsoft.Rest;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// List of available operations.
+ ///
+ public partial class OperationsListResults
+ {
+ ///
+ /// Initializes a new instance of the OperationsListResults class.
+ ///
+ public OperationsListResults()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the OperationsListResults class.
+ ///
+ /// OData entity count; represents the number
+ /// of operations returned.
+ /// List of available operations.
+ public OperationsListResults(int? odatacount = default(int?), IList value = default(IList))
+ {
+ Odatacount = odatacount;
+ Value = value;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets oData entity count; represents the number of
+ /// operations returned.
+ ///
+ [JsonProperty(PropertyName = "@odata.count")]
+ public int? Odatacount { get; set; }
+
+ ///
+ /// Gets or sets list of available operations.
+ ///
+ [JsonProperty(PropertyName = "value")]
+ public IList Value { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Odatacount < 1)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "Odatacount", 1);
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyAssignmentSummary.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyAssignmentSummary.cs
new file mode 100644
index 000000000000..fbc257997c6e
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyAssignmentSummary.cs
@@ -0,0 +1,103 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Policy assignment summary.
+ ///
+ public partial class PolicyAssignmentSummary
+ {
+ ///
+ /// Initializes a new instance of the PolicyAssignmentSummary class.
+ ///
+ public PolicyAssignmentSummary()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyAssignmentSummary class.
+ ///
+ /// Policy assignment ID.
+ /// Policy set definition ID, if
+ /// the policy assignment is for a policy set.
+ /// Non-compliance summary for the policy
+ /// assignment.
+ /// Policy definitions summary.
+ public PolicyAssignmentSummary(string policyAssignmentId = default(string), string policySetDefinitionId = default(string), SummaryResults results = default(SummaryResults), IList policyDefinitions = default(IList))
+ {
+ PolicyAssignmentId = policyAssignmentId;
+ PolicySetDefinitionId = policySetDefinitionId;
+ Results = results;
+ PolicyDefinitions = policyDefinitions;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets policy assignment ID.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentId")]
+ public string PolicyAssignmentId { get; set; }
+
+ ///
+ /// Gets or sets policy set definition ID, if the policy assignment is
+ /// for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionId")]
+ public string PolicySetDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets non-compliance summary for the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "results")]
+ public SummaryResults Results { get; set; }
+
+ ///
+ /// Gets or sets policy definitions summary.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitions")]
+ public IList PolicyDefinitions { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Results != null)
+ {
+ Results.Validate();
+ }
+ if (PolicyDefinitions != null)
+ {
+ foreach (var element in PolicyDefinitions)
+ {
+ if (element != null)
+ {
+ element.Validate();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyDefinitionSummary.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyDefinitionSummary.cs
new file mode 100644
index 000000000000..6ac1a00237f4
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyDefinitionSummary.cs
@@ -0,0 +1,82 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Policy definition summary.
+ ///
+ public partial class PolicyDefinitionSummary
+ {
+ ///
+ /// Initializes a new instance of the PolicyDefinitionSummary class.
+ ///
+ public PolicyDefinitionSummary()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyDefinitionSummary class.
+ ///
+ /// Policy definition ID.
+ /// Policy effect, i.e. policy definition
+ /// action.
+ /// Non-compliance summary for the policy
+ /// definition.
+ public PolicyDefinitionSummary(string policyDefinitionId = default(string), string effect = default(string), SummaryResults results = default(SummaryResults))
+ {
+ PolicyDefinitionId = policyDefinitionId;
+ Effect = effect;
+ Results = results;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets policy definition ID.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionId")]
+ public string PolicyDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets policy effect, i.e. policy definition action.
+ ///
+ [JsonProperty(PropertyName = "effect")]
+ public string Effect { get; set; }
+
+ ///
+ /// Gets or sets non-compliance summary for the policy definition.
+ ///
+ [JsonProperty(PropertyName = "results")]
+ public SummaryResults Results { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Results != null)
+ {
+ Results.Validate();
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyEvent.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyEvent.cs
new file mode 100644
index 000000000000..17e08951ae73
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyEvent.cs
@@ -0,0 +1,322 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Policy event record.
+ ///
+ public partial class PolicyEvent
+ {
+ ///
+ /// Initializes a new instance of the PolicyEvent class.
+ ///
+ public PolicyEvent()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyEvent class.
+ ///
+ /// Unmatched properties from the
+ /// message are deserialized this collection
+ /// OData entity ID; always set to null since
+ /// policy event records do not have an entity ID.
+ /// OData context string; used by OData
+ /// clients to resolve type information based on metadata.
+ /// Timestamp for the policy event
+ /// record.
+ /// Resource ID.
+ /// Policy assignment ID.
+ /// Policy definition ID.
+ /// Effective parameters for the
+ /// policy assignment.
+ /// Flag which states whether the resource is
+ /// compliant against the policy assignment it was evaluated
+ /// against.
+ /// Subscription ID.
+ /// Resource type.
+ /// Resource location.
+ /// Resource group name.
+ /// List of resource tags.
+ /// Policy assignment name.
+ /// Policy assignment
+ /// owner.
+ /// Policy assignment
+ /// parameters.
+ /// Policy assignment
+ /// scope.
+ /// Policy definition name.
+ /// Policy definition action, i.e.
+ /// effect.
+ /// Policy definition
+ /// category.
+ /// Policy set definition ID, if
+ /// the policy assignment is for a policy set.
+ /// Policy set definition name,
+ /// if the policy assignment is for a policy set.
+ /// Policy set definition owner,
+ /// if the policy assignment is for a policy set.
+ /// Policy set definition
+ /// category, if the policy assignment is for a policy set.
+ /// Policy set definition
+ /// parameters, if the policy assignment is for a policy set.
+ /// Comma seperated list of management
+ /// group IDs, which represent the hierarchy of the management groups
+ /// the resource is under.
+ /// Reference ID for the
+ /// policy definition inside the policy set, if the policy assignment
+ /// is for a policy set.
+ /// Tenant ID for the policy event
+ /// record.
+ /// Principal object ID for the user who
+ /// initiated the resource operation that triggered the policy
+ /// event.
+ public PolicyEvent(IDictionary additionalProperties = default(IDictionary), string odataid = default(string), string odatacontext = default(string), System.DateTime? timestamp = default(System.DateTime?), string resourceId = default(string), string policyAssignmentId = default(string), string policyDefinitionId = default(string), string effectiveParameters = default(string), bool? isCompliant = default(bool?), string subscriptionId = default(string), string resourceType = default(string), string resourceLocation = default(string), string resourceGroup = default(string), string resourceTags = default(string), string policyAssignmentName = default(string), string policyAssignmentOwner = default(string), string policyAssignmentParameters = default(string), string policyAssignmentScope = default(string), string policyDefinitionName = default(string), string policyDefinitionAction = default(string), string policyDefinitionCategory = default(string), string policySetDefinitionId = default(string), string policySetDefinitionName = default(string), string policySetDefinitionOwner = default(string), string policySetDefinitionCategory = default(string), string policySetDefinitionParameters = default(string), string managementGroupIds = default(string), string policyDefinitionReferenceId = default(string), string tenantId = default(string), string principalOid = default(string))
+ {
+ AdditionalProperties = additionalProperties;
+ Odataid = odataid;
+ Odatacontext = odatacontext;
+ Timestamp = timestamp;
+ ResourceId = resourceId;
+ PolicyAssignmentId = policyAssignmentId;
+ PolicyDefinitionId = policyDefinitionId;
+ EffectiveParameters = effectiveParameters;
+ IsCompliant = isCompliant;
+ SubscriptionId = subscriptionId;
+ ResourceType = resourceType;
+ ResourceLocation = resourceLocation;
+ ResourceGroup = resourceGroup;
+ ResourceTags = resourceTags;
+ PolicyAssignmentName = policyAssignmentName;
+ PolicyAssignmentOwner = policyAssignmentOwner;
+ PolicyAssignmentParameters = policyAssignmentParameters;
+ PolicyAssignmentScope = policyAssignmentScope;
+ PolicyDefinitionName = policyDefinitionName;
+ PolicyDefinitionAction = policyDefinitionAction;
+ PolicyDefinitionCategory = policyDefinitionCategory;
+ PolicySetDefinitionId = policySetDefinitionId;
+ PolicySetDefinitionName = policySetDefinitionName;
+ PolicySetDefinitionOwner = policySetDefinitionOwner;
+ PolicySetDefinitionCategory = policySetDefinitionCategory;
+ PolicySetDefinitionParameters = policySetDefinitionParameters;
+ ManagementGroupIds = managementGroupIds;
+ PolicyDefinitionReferenceId = policyDefinitionReferenceId;
+ TenantId = tenantId;
+ PrincipalOid = principalOid;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets unmatched properties from the message are deserialized
+ /// this collection
+ ///
+ [JsonExtensionData]
+ public IDictionary AdditionalProperties { get; set; }
+
+ ///
+ /// Gets or sets oData entity ID; always set to null since policy event
+ /// records do not have an entity ID.
+ ///
+ [JsonProperty(PropertyName = "@odata.id")]
+ public string Odataid { get; set; }
+
+ ///
+ /// Gets or sets oData context string; used by OData clients to resolve
+ /// type information based on metadata.
+ ///
+ [JsonProperty(PropertyName = "@odata.context")]
+ public string Odatacontext { get; set; }
+
+ ///
+ /// Gets or sets timestamp for the policy event record.
+ ///
+ [JsonProperty(PropertyName = "timestamp")]
+ public System.DateTime? Timestamp { get; set; }
+
+ ///
+ /// Gets or sets resource ID.
+ ///
+ [JsonProperty(PropertyName = "resourceId")]
+ public string ResourceId { get; set; }
+
+ ///
+ /// Gets or sets policy assignment ID.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentId")]
+ public string PolicyAssignmentId { get; set; }
+
+ ///
+ /// Gets or sets policy definition ID.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionId")]
+ public string PolicyDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets effective parameters for the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "effectiveParameters")]
+ public string EffectiveParameters { get; set; }
+
+ ///
+ /// Gets or sets flag which states whether the resource is compliant
+ /// against the policy assignment it was evaluated against.
+ ///
+ [JsonProperty(PropertyName = "isCompliant")]
+ public bool? IsCompliant { get; set; }
+
+ ///
+ /// Gets or sets subscription ID.
+ ///
+ [JsonProperty(PropertyName = "subscriptionId")]
+ public string SubscriptionId { get; set; }
+
+ ///
+ /// Gets or sets resource type.
+ ///
+ [JsonProperty(PropertyName = "resourceType")]
+ public string ResourceType { get; set; }
+
+ ///
+ /// Gets or sets resource location.
+ ///
+ [JsonProperty(PropertyName = "resourceLocation")]
+ public string ResourceLocation { get; set; }
+
+ ///
+ /// Gets or sets resource group name.
+ ///
+ [JsonProperty(PropertyName = "resourceGroup")]
+ public string ResourceGroup { get; set; }
+
+ ///
+ /// Gets or sets list of resource tags.
+ ///
+ [JsonProperty(PropertyName = "resourceTags")]
+ public string ResourceTags { get; set; }
+
+ ///
+ /// Gets or sets policy assignment name.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentName")]
+ public string PolicyAssignmentName { get; set; }
+
+ ///
+ /// Gets or sets policy assignment owner.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentOwner")]
+ public string PolicyAssignmentOwner { get; set; }
+
+ ///
+ /// Gets or sets policy assignment parameters.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentParameters")]
+ public string PolicyAssignmentParameters { get; set; }
+
+ ///
+ /// Gets or sets policy assignment scope.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentScope")]
+ public string PolicyAssignmentScope { get; set; }
+
+ ///
+ /// Gets or sets policy definition name.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionName")]
+ public string PolicyDefinitionName { get; set; }
+
+ ///
+ /// Gets or sets policy definition action, i.e. effect.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionAction")]
+ public string PolicyDefinitionAction { get; set; }
+
+ ///
+ /// Gets or sets policy definition category.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionCategory")]
+ public string PolicyDefinitionCategory { get; set; }
+
+ ///
+ /// Gets or sets policy set definition ID, if the policy assignment is
+ /// for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionId")]
+ public string PolicySetDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets policy set definition name, if the policy assignment
+ /// is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionName")]
+ public string PolicySetDefinitionName { get; set; }
+
+ ///
+ /// Gets or sets policy set definition owner, if the policy assignment
+ /// is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionOwner")]
+ public string PolicySetDefinitionOwner { get; set; }
+
+ ///
+ /// Gets or sets policy set definition category, if the policy
+ /// assignment is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionCategory")]
+ public string PolicySetDefinitionCategory { get; set; }
+
+ ///
+ /// Gets or sets policy set definition parameters, if the policy
+ /// assignment is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionParameters")]
+ public string PolicySetDefinitionParameters { get; set; }
+
+ ///
+ /// Gets or sets comma seperated list of management group IDs, which
+ /// represent the hierarchy of the management groups the resource is
+ /// under.
+ ///
+ [JsonProperty(PropertyName = "managementGroupIds")]
+ public string ManagementGroupIds { get; set; }
+
+ ///
+ /// Gets or sets reference ID for the policy definition inside the
+ /// policy set, if the policy assignment is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionReferenceId")]
+ public string PolicyDefinitionReferenceId { get; set; }
+
+ ///
+ /// Gets or sets tenant ID for the policy event record.
+ ///
+ [JsonProperty(PropertyName = "tenantId")]
+ public string TenantId { get; set; }
+
+ ///
+ /// Gets or sets principal object ID for the user who initiated the
+ /// resource operation that triggered the policy event.
+ ///
+ [JsonProperty(PropertyName = "principalOid")]
+ public string PrincipalOid { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyEventsQueryResults.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyEventsQueryResults.cs
new file mode 100644
index 000000000000..7d194f68d0b7
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyEventsQueryResults.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Microsoft.Rest;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Query results.
+ ///
+ public partial class PolicyEventsQueryResults
+ {
+ ///
+ /// Initializes a new instance of the PolicyEventsQueryResults class.
+ ///
+ public PolicyEventsQueryResults()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyEventsQueryResults class.
+ ///
+ /// OData context string; used by OData
+ /// clients to resolve type information based on metadata.
+ /// OData entity count; represents the number
+ /// of policy event records returned.
+ /// Query results.
+ public PolicyEventsQueryResults(string odatacontext = default(string), int? odatacount = default(int?), IList value = default(IList))
+ {
+ Odatacontext = odatacontext;
+ Odatacount = odatacount;
+ Value = value;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets oData context string; used by OData clients to resolve
+ /// type information based on metadata.
+ ///
+ [JsonProperty(PropertyName = "@odata.context")]
+ public string Odatacontext { get; set; }
+
+ ///
+ /// Gets or sets oData entity count; represents the number of policy
+ /// event records returned.
+ ///
+ [JsonProperty(PropertyName = "@odata.count")]
+ public int? Odatacount { get; set; }
+
+ ///
+ /// Gets or sets query results.
+ ///
+ [JsonProperty(PropertyName = "value")]
+ public IList Value { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Odatacount < 0)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "Odatacount", 0);
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyState.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyState.cs
new file mode 100644
index 000000000000..5cb9a5a8f85c
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyState.cs
@@ -0,0 +1,302 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Policy state record.
+ ///
+ public partial class PolicyState
+ {
+ ///
+ /// Initializes a new instance of the PolicyState class.
+ ///
+ public PolicyState()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyState class.
+ ///
+ /// Unmatched properties from the
+ /// message are deserialized this collection
+ /// OData entity ID; always set to null since
+ /// policy state records do not have an entity ID.
+ /// OData context string; used by OData
+ /// clients to resolve type information based on metadata.
+ /// Timestamp for the policy state
+ /// record.
+ /// Resource ID.
+ /// Policy assignment ID.
+ /// Policy definition ID.
+ /// Effective parameters for the
+ /// policy assignment.
+ /// Flag which states whether the resource is
+ /// compliant against the policy assignment it was evaluated
+ /// against.
+ /// Subscription ID.
+ /// Resource type.
+ /// Resource location.
+ /// Resource group name.
+ /// List of resource tags.
+ /// Policy assignment name.
+ /// Policy assignment
+ /// owner.
+ /// Policy assignment
+ /// parameters.
+ /// Policy assignment
+ /// scope.
+ /// Policy definition name.
+ /// Policy definition action, i.e.
+ /// effect.
+ /// Policy definition
+ /// category.
+ /// Policy set definition ID, if
+ /// the policy assignment is for a policy set.
+ /// Policy set definition name,
+ /// if the policy assignment is for a policy set.
+ /// Policy set definition owner,
+ /// if the policy assignment is for a policy set.
+ /// Policy set definition
+ /// category, if the policy assignment is for a policy set.
+ /// Policy set definition
+ /// parameters, if the policy assignment is for a policy set.
+ /// Comma seperated list of management
+ /// group IDs, which represent the hierarchy of the management groups
+ /// the resource is under.
+ /// Reference ID for the
+ /// policy definition inside the policy set, if the policy assignment
+ /// is for a policy set.
+ public PolicyState(IDictionary additionalProperties = default(IDictionary), string odataid = default(string), string odatacontext = default(string), System.DateTime? timestamp = default(System.DateTime?), string resourceId = default(string), string policyAssignmentId = default(string), string policyDefinitionId = default(string), string effectiveParameters = default(string), bool? isCompliant = default(bool?), string subscriptionId = default(string), string resourceType = default(string), string resourceLocation = default(string), string resourceGroup = default(string), string resourceTags = default(string), string policyAssignmentName = default(string), string policyAssignmentOwner = default(string), string policyAssignmentParameters = default(string), string policyAssignmentScope = default(string), string policyDefinitionName = default(string), string policyDefinitionAction = default(string), string policyDefinitionCategory = default(string), string policySetDefinitionId = default(string), string policySetDefinitionName = default(string), string policySetDefinitionOwner = default(string), string policySetDefinitionCategory = default(string), string policySetDefinitionParameters = default(string), string managementGroupIds = default(string), string policyDefinitionReferenceId = default(string))
+ {
+ AdditionalProperties = additionalProperties;
+ Odataid = odataid;
+ Odatacontext = odatacontext;
+ Timestamp = timestamp;
+ ResourceId = resourceId;
+ PolicyAssignmentId = policyAssignmentId;
+ PolicyDefinitionId = policyDefinitionId;
+ EffectiveParameters = effectiveParameters;
+ IsCompliant = isCompliant;
+ SubscriptionId = subscriptionId;
+ ResourceType = resourceType;
+ ResourceLocation = resourceLocation;
+ ResourceGroup = resourceGroup;
+ ResourceTags = resourceTags;
+ PolicyAssignmentName = policyAssignmentName;
+ PolicyAssignmentOwner = policyAssignmentOwner;
+ PolicyAssignmentParameters = policyAssignmentParameters;
+ PolicyAssignmentScope = policyAssignmentScope;
+ PolicyDefinitionName = policyDefinitionName;
+ PolicyDefinitionAction = policyDefinitionAction;
+ PolicyDefinitionCategory = policyDefinitionCategory;
+ PolicySetDefinitionId = policySetDefinitionId;
+ PolicySetDefinitionName = policySetDefinitionName;
+ PolicySetDefinitionOwner = policySetDefinitionOwner;
+ PolicySetDefinitionCategory = policySetDefinitionCategory;
+ PolicySetDefinitionParameters = policySetDefinitionParameters;
+ ManagementGroupIds = managementGroupIds;
+ PolicyDefinitionReferenceId = policyDefinitionReferenceId;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets unmatched properties from the message are deserialized
+ /// this collection
+ ///
+ [JsonExtensionData]
+ public IDictionary AdditionalProperties { get; set; }
+
+ ///
+ /// Gets or sets oData entity ID; always set to null since policy state
+ /// records do not have an entity ID.
+ ///
+ [JsonProperty(PropertyName = "@odata.id")]
+ public string Odataid { get; set; }
+
+ ///
+ /// Gets or sets oData context string; used by OData clients to resolve
+ /// type information based on metadata.
+ ///
+ [JsonProperty(PropertyName = "@odata.context")]
+ public string Odatacontext { get; set; }
+
+ ///
+ /// Gets or sets timestamp for the policy state record.
+ ///
+ [JsonProperty(PropertyName = "timestamp")]
+ public System.DateTime? Timestamp { get; set; }
+
+ ///
+ /// Gets or sets resource ID.
+ ///
+ [JsonProperty(PropertyName = "resourceId")]
+ public string ResourceId { get; set; }
+
+ ///
+ /// Gets or sets policy assignment ID.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentId")]
+ public string PolicyAssignmentId { get; set; }
+
+ ///
+ /// Gets or sets policy definition ID.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionId")]
+ public string PolicyDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets effective parameters for the policy assignment.
+ ///
+ [JsonProperty(PropertyName = "effectiveParameters")]
+ public string EffectiveParameters { get; set; }
+
+ ///
+ /// Gets or sets flag which states whether the resource is compliant
+ /// against the policy assignment it was evaluated against.
+ ///
+ [JsonProperty(PropertyName = "isCompliant")]
+ public bool? IsCompliant { get; set; }
+
+ ///
+ /// Gets or sets subscription ID.
+ ///
+ [JsonProperty(PropertyName = "subscriptionId")]
+ public string SubscriptionId { get; set; }
+
+ ///
+ /// Gets or sets resource type.
+ ///
+ [JsonProperty(PropertyName = "resourceType")]
+ public string ResourceType { get; set; }
+
+ ///
+ /// Gets or sets resource location.
+ ///
+ [JsonProperty(PropertyName = "resourceLocation")]
+ public string ResourceLocation { get; set; }
+
+ ///
+ /// Gets or sets resource group name.
+ ///
+ [JsonProperty(PropertyName = "resourceGroup")]
+ public string ResourceGroup { get; set; }
+
+ ///
+ /// Gets or sets list of resource tags.
+ ///
+ [JsonProperty(PropertyName = "resourceTags")]
+ public string ResourceTags { get; set; }
+
+ ///
+ /// Gets or sets policy assignment name.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentName")]
+ public string PolicyAssignmentName { get; set; }
+
+ ///
+ /// Gets or sets policy assignment owner.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentOwner")]
+ public string PolicyAssignmentOwner { get; set; }
+
+ ///
+ /// Gets or sets policy assignment parameters.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentParameters")]
+ public string PolicyAssignmentParameters { get; set; }
+
+ ///
+ /// Gets or sets policy assignment scope.
+ ///
+ [JsonProperty(PropertyName = "policyAssignmentScope")]
+ public string PolicyAssignmentScope { get; set; }
+
+ ///
+ /// Gets or sets policy definition name.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionName")]
+ public string PolicyDefinitionName { get; set; }
+
+ ///
+ /// Gets or sets policy definition action, i.e. effect.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionAction")]
+ public string PolicyDefinitionAction { get; set; }
+
+ ///
+ /// Gets or sets policy definition category.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionCategory")]
+ public string PolicyDefinitionCategory { get; set; }
+
+ ///
+ /// Gets or sets policy set definition ID, if the policy assignment is
+ /// for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionId")]
+ public string PolicySetDefinitionId { get; set; }
+
+ ///
+ /// Gets or sets policy set definition name, if the policy assignment
+ /// is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionName")]
+ public string PolicySetDefinitionName { get; set; }
+
+ ///
+ /// Gets or sets policy set definition owner, if the policy assignment
+ /// is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionOwner")]
+ public string PolicySetDefinitionOwner { get; set; }
+
+ ///
+ /// Gets or sets policy set definition category, if the policy
+ /// assignment is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionCategory")]
+ public string PolicySetDefinitionCategory { get; set; }
+
+ ///
+ /// Gets or sets policy set definition parameters, if the policy
+ /// assignment is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policySetDefinitionParameters")]
+ public string PolicySetDefinitionParameters { get; set; }
+
+ ///
+ /// Gets or sets comma seperated list of management group IDs, which
+ /// represent the hierarchy of the management groups the resource is
+ /// under.
+ ///
+ [JsonProperty(PropertyName = "managementGroupIds")]
+ public string ManagementGroupIds { get; set; }
+
+ ///
+ /// Gets or sets reference ID for the policy definition inside the
+ /// policy set, if the policy assignment is for a policy set.
+ ///
+ [JsonProperty(PropertyName = "policyDefinitionReferenceId")]
+ public string PolicyDefinitionReferenceId { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyStatesQueryResults.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyStatesQueryResults.cs
new file mode 100644
index 000000000000..f13fbeec6a42
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyStatesQueryResults.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Microsoft.Rest;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Query results.
+ ///
+ public partial class PolicyStatesQueryResults
+ {
+ ///
+ /// Initializes a new instance of the PolicyStatesQueryResults class.
+ ///
+ public PolicyStatesQueryResults()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyStatesQueryResults class.
+ ///
+ /// OData context string; used by OData
+ /// clients to resolve type information based on metadata.
+ /// OData entity count; represents the number
+ /// of policy state records returned.
+ /// Query results.
+ public PolicyStatesQueryResults(string odatacontext = default(string), int? odatacount = default(int?), IList value = default(IList))
+ {
+ Odatacontext = odatacontext;
+ Odatacount = odatacount;
+ Value = value;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets oData context string; used by OData clients to resolve
+ /// type information based on metadata.
+ ///
+ [JsonProperty(PropertyName = "@odata.context")]
+ public string Odatacontext { get; set; }
+
+ ///
+ /// Gets or sets oData entity count; represents the number of policy
+ /// state records returned.
+ ///
+ [JsonProperty(PropertyName = "@odata.count")]
+ public int? Odatacount { get; set; }
+
+ ///
+ /// Gets or sets query results.
+ ///
+ [JsonProperty(PropertyName = "value")]
+ public IList Value { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Odatacount < 0)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "Odatacount", 0);
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyStatesResource.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyStatesResource.cs
new file mode 100644
index 000000000000..347d82cbcd55
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/PolicyStatesResource.cs
@@ -0,0 +1,22 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+
+ ///
+ /// Defines values for PolicyStatesResource.
+ ///
+ public static class PolicyStatesResource
+ {
+ public const string Default = "default";
+ public const string Latest = "latest";
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailure.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailure.cs
new file mode 100644
index 000000000000..8b4544cebc0b
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailure.cs
@@ -0,0 +1,51 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Error response.
+ ///
+ public partial class QueryFailure
+ {
+ ///
+ /// Initializes a new instance of the QueryFailure class.
+ ///
+ public QueryFailure()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the QueryFailure class.
+ ///
+ /// Error definition.
+ public QueryFailure(QueryFailureError error = default(QueryFailureError))
+ {
+ Error = error;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets error definition.
+ ///
+ [JsonProperty(PropertyName = "error")]
+ public QueryFailureError Error { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailureError.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailureError.cs
new file mode 100644
index 000000000000..fdc47dcefcf1
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailureError.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Error definition.
+ ///
+ public partial class QueryFailureError
+ {
+ ///
+ /// Initializes a new instance of the QueryFailureError class.
+ ///
+ public QueryFailureError()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the QueryFailureError class.
+ ///
+ /// Service specific error code which serves as the
+ /// substatus for the HTTP error code.
+ /// Description of the error.
+ public QueryFailureError(string code = default(string), string message = default(string))
+ {
+ Code = code;
+ Message = message;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets service specific error code which serves as the
+ /// substatus for the HTTP error code.
+ ///
+ [JsonProperty(PropertyName = "code")]
+ public string Code { get; set; }
+
+ ///
+ /// Gets or sets description of the error.
+ ///
+ [JsonProperty(PropertyName = "message")]
+ public string Message { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailureException.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailureException.cs
new file mode 100644
index 000000000000..8c5361422551
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryFailureException.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Microsoft.Rest;
+
+ ///
+ /// Exception thrown for an invalid response with QueryFailure information.
+ ///
+ public partial class QueryFailureException : 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 QueryFailure Body { get; set; }
+
+ ///
+ /// Initializes a new instance of the QueryFailureException class.
+ ///
+ public QueryFailureException()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the QueryFailureException class.
+ ///
+ /// The exception message.
+ public QueryFailureException(string message)
+ : this(message, null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the QueryFailureException class.
+ ///
+ /// The exception message.
+ /// Inner exception.
+ public QueryFailureException(string message, System.Exception innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryOptions.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryOptions.cs
new file mode 100644
index 000000000000..b25e8de16d9f
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/QueryOptions.cs
@@ -0,0 +1,117 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Additional parameters for a set of operations.
+ ///
+ public partial class QueryOptions
+ {
+ ///
+ /// Initializes a new instance of the QueryOptions class.
+ ///
+ public QueryOptions()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the QueryOptions class.
+ ///
+ /// Maximum number of records to return.
+ /// Ordering expression using OData notation. One
+ /// or more comma-separated column names with an optional "desc" (the
+ /// default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId
+ /// asc".
+ /// Select expression using OData notation. Limits
+ /// the columns on each record to just those requested, e.g.
+ /// "$select=PolicyAssignmentId, ResourceId".
+ /// ISO 8601 formatted timestamp specifying
+ /// the start time of the interval to query. When not specified, the
+ /// service uses ($to - 1-day).
+ /// ISO 8601 formatted timestamp specifying the end
+ /// time of the interval to query. When not specified, the service uses
+ /// request time.
+ /// OData filter expression.
+ /// OData apply expression for
+ /// aggregations.
+ public QueryOptions(int? top = default(int?), string orderBy = default(string), string select = default(string), System.DateTime? fromProperty = default(System.DateTime?), System.DateTime? to = default(System.DateTime?), string filter = default(string), string apply = default(string))
+ {
+ Top = top;
+ OrderBy = orderBy;
+ Select = select;
+ FromProperty = fromProperty;
+ To = to;
+ Filter = filter;
+ Apply = apply;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets maximum number of records to return.
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public int? Top { get; set; }
+
+ ///
+ /// Gets or sets ordering expression using OData notation. One or more
+ /// comma-separated column names with an optional "desc" (the default)
+ /// or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc".
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public string OrderBy { get; set; }
+
+ ///
+ /// Gets or sets select expression using OData notation. Limits the
+ /// columns on each record to just those requested, e.g.
+ /// "$select=PolicyAssignmentId, ResourceId".
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public string Select { get; set; }
+
+ ///
+ /// Gets or sets ISO 8601 formatted timestamp specifying the start time
+ /// of the interval to query. When not specified, the service uses ($to
+ /// - 1-day).
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public System.DateTime? FromProperty { get; set; }
+
+ ///
+ /// Gets or sets ISO 8601 formatted timestamp specifying the end time
+ /// of the interval to query. When not specified, the service uses
+ /// request time.
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public System.DateTime? To { get; set; }
+
+ ///
+ /// Gets or sets oData filter expression.
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public string Filter { get; set; }
+
+ ///
+ /// Gets or sets oData apply expression for aggregations.
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public string Apply { get; set; }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/SummarizeResults.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/SummarizeResults.cs
new file mode 100644
index 000000000000..c81b31a842db
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/SummarizeResults.cs
@@ -0,0 +1,101 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Microsoft.Rest;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Summarize action results.
+ ///
+ public partial class SummarizeResults
+ {
+ ///
+ /// Initializes a new instance of the SummarizeResults class.
+ ///
+ public SummarizeResults()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the SummarizeResults class.
+ ///
+ /// OData context string; used by OData
+ /// clients to resolve type information based on metadata.
+ /// OData entity count; represents the number
+ /// of summaries returned; always set to 1.
+ /// Summarize action results.
+ public SummarizeResults(string odatacontext = default(string), int? odatacount = default(int?), IList value = default(IList))
+ {
+ Odatacontext = odatacontext;
+ Odatacount = odatacount;
+ Value = value;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets oData context string; used by OData clients to resolve
+ /// type information based on metadata.
+ ///
+ [JsonProperty(PropertyName = "@odata.context")]
+ public string Odatacontext { get; set; }
+
+ ///
+ /// Gets or sets oData entity count; represents the number of summaries
+ /// returned; always set to 1.
+ ///
+ [JsonProperty(PropertyName = "@odata.count")]
+ public int? Odatacount { get; set; }
+
+ ///
+ /// Gets or sets summarize action results.
+ ///
+ [JsonProperty(PropertyName = "value")]
+ public IList Value { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Odatacount > 1)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMaximum, "Odatacount", 1);
+ }
+ if (Odatacount < 1)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "Odatacount", 1);
+ }
+ if (Value != null)
+ {
+ foreach (var element in Value)
+ {
+ if (element != null)
+ {
+ element.Validate();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/Summary.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/Summary.cs
new file mode 100644
index 000000000000..7296e4058843
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/Summary.cs
@@ -0,0 +1,105 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// Summary results.
+ ///
+ public partial class Summary
+ {
+ ///
+ /// Initializes a new instance of the Summary class.
+ ///
+ public Summary()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the Summary class.
+ ///
+ /// OData entity ID; always set to null since
+ /// summaries do not have an entity ID.
+ /// OData context string; used by OData
+ /// clients to resolve type information based on metadata.
+ /// Non-compliance summary for all policy
+ /// assignments.
+ /// Policy assignments summary.
+ public Summary(string odataid = default(string), string odatacontext = default(string), SummaryResults results = default(SummaryResults), IList policyAssignments = default(IList))
+ {
+ Odataid = odataid;
+ Odatacontext = odatacontext;
+ Results = results;
+ PolicyAssignments = policyAssignments;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets oData entity ID; always set to null since summaries do
+ /// not have an entity ID.
+ ///
+ [JsonProperty(PropertyName = "@odata.id")]
+ public string Odataid { get; set; }
+
+ ///
+ /// Gets or sets oData context string; used by OData clients to resolve
+ /// type information based on metadata.
+ ///
+ [JsonProperty(PropertyName = "@odata.context")]
+ public string Odatacontext { get; set; }
+
+ ///
+ /// Gets or sets non-compliance summary for all policy assignments.
+ ///
+ [JsonProperty(PropertyName = "results")]
+ public SummaryResults Results { get; set; }
+
+ ///
+ /// Gets or sets policy assignments summary.
+ ///
+ [JsonProperty(PropertyName = "policyAssignments")]
+ public IList PolicyAssignments { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (Results != null)
+ {
+ Results.Validate();
+ }
+ if (PolicyAssignments != null)
+ {
+ foreach (var element in PolicyAssignments)
+ {
+ if (element != null)
+ {
+ element.Validate();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/SummaryResults.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/SummaryResults.cs
new file mode 100644
index 000000000000..1eae3a246690
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Models/SummaryResults.cs
@@ -0,0 +1,91 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights.Models
+{
+ using Microsoft.Rest;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Non-compliance summary on a particular summary level.
+ ///
+ public partial class SummaryResults
+ {
+ ///
+ /// Initializes a new instance of the SummaryResults class.
+ ///
+ public SummaryResults()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the SummaryResults class.
+ ///
+ /// HTTP POST URI for queryResults action
+ /// on Microsoft.PolicyInsights to retrieve raw results for the
+ /// non-compliance summary.
+ /// Number of non-compliant
+ /// resources.
+ /// Number of non-compliant
+ /// policies.
+ public SummaryResults(string queryResultsUri = default(string), int? nonCompliantResources = default(int?), int? nonCompliantPolicies = default(int?))
+ {
+ QueryResultsUri = queryResultsUri;
+ NonCompliantResources = nonCompliantResources;
+ NonCompliantPolicies = nonCompliantPolicies;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets HTTP POST URI for queryResults action on
+ /// Microsoft.PolicyInsights to retrieve raw results for the
+ /// non-compliance summary.
+ ///
+ [JsonProperty(PropertyName = "queryResultsUri")]
+ public string QueryResultsUri { get; set; }
+
+ ///
+ /// Gets or sets number of non-compliant resources.
+ ///
+ [JsonProperty(PropertyName = "nonCompliantResources")]
+ public int? NonCompliantResources { get; set; }
+
+ ///
+ /// Gets or sets number of non-compliant policies.
+ ///
+ [JsonProperty(PropertyName = "nonCompliantPolicies")]
+ public int? NonCompliantPolicies { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (NonCompliantResources < 0)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "NonCompliantResources", 0);
+ }
+ if (NonCompliantPolicies < 0)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "NonCompliantPolicies", 0);
+ }
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Operations.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Operations.cs
new file mode 100644
index 000000000000..45345e07a979
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/Operations.cs
@@ -0,0 +1,222 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Operations operations.
+ ///
+ internal partial class Operations : IServiceOperations, IOperations
+ {
+ ///
+ /// Initializes a new instance of the Operations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal Operations(PolicyInsightsClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the PolicyInsightsClient
+ ///
+ public PolicyInsightsClient Client { get; private set; }
+
+ ///
+ /// Lists available operations.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.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("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.PolicyInsights/operations").ToString();
+ 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 QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/OperationsExtensions.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/OperationsExtensions.cs
new file mode 100644
index 000000000000..194986ab7fc8
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/OperationsExtensions.cs
@@ -0,0 +1,53 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for Operations.
+ ///
+ public static partial class OperationsExtensions
+ {
+ ///
+ /// Lists available operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ public static OperationsListResults List(this IOperations operations)
+ {
+ return operations.ListAsync().GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists available operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyEventsOperations.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyEventsOperations.cs
new file mode 100644
index 000000000000..5967959da11d
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyEventsOperations.cs
@@ -0,0 +1,2325 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicyEventsOperations operations.
+ ///
+ internal partial class PolicyEventsOperations : IServiceOperations, IPolicyEventsOperations
+ {
+ ///
+ /// Initializes a new instance of the PolicyEventsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal PolicyEventsOperations(PolicyInsightsClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the PolicyInsightsClient
+ ///
+ public PolicyInsightsClient Client { get; private set; }
+
+ ///
+ /// Queries policy events for the resources under the management group.
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (managementGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ string managementGroupsNamespace = "Microsoft.Management";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("managementGroupsNamespace", managementGroupsNamespace);
+ tracingParameters.Add("managementGroupName", managementGroupName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForManagementGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{managementGroupsNamespace}", System.Uri.EscapeDataString(managementGroupsNamespace));
+ _url = _url.Replace("{managementGroupName}", System.Uri.EscapeDataString(managementGroupName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the resources under the subscription.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscription", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the resources under the resource group.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (resourceGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("resourceGroupName", resourceGroupName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the resource.
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (resourceId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("resourceId", resourceId);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResource", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{resourceId}", resourceId);
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy set definition.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy set definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (policySetDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ string authorizationNamespace = "Microsoft.Authorization";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("authorizationNamespace", authorizationNamespace);
+ tracingParameters.Add("policySetDefinitionName", policySetDefinitionName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicySetDefinition", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{authorizationNamespace}", System.Uri.EscapeDataString(authorizationNamespace));
+ _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy definition.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (policyDefinitionName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ string authorizationNamespace = "Microsoft.Authorization";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("authorizationNamespace", authorizationNamespace);
+ tracingParameters.Add("policyDefinitionName", policyDefinitionName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicyDefinition", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{authorizationNamespace}", System.Uri.EscapeDataString(authorizationNamespace));
+ _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy assignment.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (policyAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ string authorizationNamespace = "Microsoft.Authorization";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("authorizationNamespace", authorizationNamespace);
+ tracingParameters.Add("policyAssignmentName", policyAssignmentName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionLevelPolicyAssignment", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{authorizationNamespace}", System.Uri.EscapeDataString(authorizationNamespace));
+ _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 (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy events for the resource group level policy assignment.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (resourceGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
+ }
+ if (policyAssignmentName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyEventsResource = "default";
+ string authorizationNamespace = "Microsoft.Authorization";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyEventsResource", policyEventsResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("resourceGroupName", resourceGroupName);
+ tracingParameters.Add("authorizationNamespace", authorizationNamespace);
+ tracingParameters.Add("policyAssignmentName", policyAssignmentName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupLevelPolicyAssignment", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults").ToString();
+ _url = _url.Replace("{policyEventsResource}", System.Uri.EscapeDataString(policyEventsResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
+ _url = _url.Replace("{authorizationNamespace}", System.Uri.EscapeDataString(authorizationNamespace));
+ _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 (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets OData metadata XML document.
+ ///
+ ///
+ /// A valid scope, i.e. management group, subscription, resource group, or
+ /// resource ID. Scope used has no effect on metadata returned.
+ ///
+ ///
+ /// 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> GetMetadataWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (scope == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "scope");
+ }
+ 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("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetMetadata", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.PolicyInsights/policyEvents/$metadata").ToString();
+ _url = _url.Replace("{scope}", scope);
+ 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 QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyEventsOperationsExtensions.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyEventsOperationsExtensions.cs
new file mode 100644
index 000000000000..8992e8b3f09b
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyEventsOperationsExtensions.cs
@@ -0,0 +1,417 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for PolicyEventsOperations.
+ ///
+ public static partial class PolicyEventsOperationsExtensions
+ {
+ ///
+ /// Queries policy events for the resources under the management group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForManagementGroup(this IPolicyEventsOperations operations, string managementGroupName, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForManagementGroupAsync(managementGroupName, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the resources under the management group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForManagementGroupAsync(this IPolicyEventsOperations operations, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForManagementGroupWithHttpMessagesAsync(managementGroupName, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the resources under the subscription.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForSubscription(this IPolicyEventsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForSubscriptionAsync(subscriptionId, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the resources under the subscription.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForSubscriptionAsync(this IPolicyEventsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForSubscriptionWithHttpMessagesAsync(subscriptionId, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the resources under the resource group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForResourceGroup(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForResourceGroupAsync(subscriptionId, resourceGroupName, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the resources under the resource group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForResourceGroupAsync(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForResourceGroupWithHttpMessagesAsync(subscriptionId, resourceGroupName, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForResource(this IPolicyEventsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForResourceAsync(resourceId, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForResourceAsync(this IPolicyEventsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForResourceWithHttpMessagesAsync(resourceId, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy set definition.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy set definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForPolicySetDefinition(this IPolicyEventsOperations operations, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForPolicySetDefinitionAsync(subscriptionId, policySetDefinitionName, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy set definition.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy set definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForPolicySetDefinitionAsync(this IPolicyEventsOperations operations, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(subscriptionId, policySetDefinitionName, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy definition.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForPolicyDefinition(this IPolicyEventsOperations operations, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForPolicyDefinitionAsync(subscriptionId, policyDefinitionName, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy definition.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy definition name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForPolicyDefinitionAsync(this IPolicyEventsOperations operations, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(subscriptionId, policyDefinitionName, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy assignment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForSubscriptionLevelPolicyAssignment(this IPolicyEventsOperations operations, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(subscriptionId, policyAssignmentName, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the subscription level policy assignment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(this IPolicyEventsOperations operations, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(subscriptionId, policyAssignmentName, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Queries policy events for the resource group level policy assignment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ public static PolicyEventsQueryResults ListQueryResultsForResourceGroupLevelPolicyAssignment(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions))
+ {
+ return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(subscriptionId, resourceGroupName, policyAssignmentName, queryOptions).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Queries policy events for the resource group level policy assignment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Policy assignment name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(subscriptionId, resourceGroupName, policyAssignmentName, queryOptions, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets OData metadata XML document.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A valid scope, i.e. management group, subscription, resource group, or
+ /// resource ID. Scope used has no effect on metadata returned.
+ ///
+ public static string GetMetadata(this IPolicyEventsOperations operations, string scope)
+ {
+ return operations.GetMetadataAsync(scope).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets OData metadata XML document.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A valid scope, i.e. management group, subscription, resource group, or
+ /// resource ID. Scope used has no effect on metadata returned.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetMetadataAsync(this IPolicyEventsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetMetadataWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyInsightsClient.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyInsightsClient.cs
new file mode 100644
index 000000000000..669a18a9cebd
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyInsightsClient.cs
@@ -0,0 +1,321 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using 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;
+
+ public partial class PolicyInsightsClient : ServiceClient, IPolicyInsightsClient, 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; }
+
+ ///
+ /// API version to use with the client requests.
+ ///
+ public string ApiVersion { get; private set; }
+
+ ///
+ /// Gets or sets the preferred language for the response.
+ ///
+ public string AcceptLanguage { get; set; }
+
+ ///
+ /// Gets or sets the retry timeout in seconds for Long Running Operations.
+ /// Default value is 30.
+ ///
+ public int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// 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 IPolicyEventsOperations.
+ ///
+ public virtual IPolicyEventsOperations PolicyEvents { get; private set; }
+
+ ///
+ /// Gets the IPolicyStatesOperations.
+ ///
+ public virtual IPolicyStatesOperations PolicyStates { get; private set; }
+
+ ///
+ /// Gets the IOperations.
+ ///
+ public virtual IOperations Operations { get; private set; }
+
+ ///
+ /// Initializes a new instance of the PolicyInsightsClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected PolicyInsightsClient(params DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyInsightsClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected PolicyInsightsClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyInsightsClient 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 PolicyInsightsClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the PolicyInsightsClient 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 PolicyInsightsClient(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 PolicyInsightsClient 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 PolicyInsightsClient(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 PolicyInsightsClient 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 PolicyInsightsClient(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 PolicyInsightsClient 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 PolicyInsightsClient(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 PolicyInsightsClient 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 PolicyInsightsClient(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()
+ {
+ PolicyEvents = new PolicyEventsOperations(this);
+ PolicyStates = new PolicyStatesOperations(this);
+ Operations = new Operations(this);
+ BaseUri = new System.Uri("https://management.azure.com");
+ ApiVersion = "2017-12-12-preview";
+ 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()
+ }
+ };
+ 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 CloudErrorJsonConverter());
+ }
+ }
+}
diff --git a/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyStatesOperations.cs b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyStatesOperations.cs
new file mode 100644
index 000000000000..4f6082e9cd73
--- /dev/null
+++ b/src/SDKs/PolicyInsights/Management/Management.PolicyInsights/Generated/PolicyStatesOperations.cs
@@ -0,0 +1,4250 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.PolicyInsights
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// PolicyStatesOperations operations.
+ ///
+ internal partial class PolicyStatesOperations : IServiceOperations, IPolicyStatesOperations
+ {
+ ///
+ /// Initializes a new instance of the PolicyStatesOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal PolicyStatesOperations(PolicyInsightsClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the PolicyInsightsClient
+ ///
+ public PolicyInsightsClient Client { get; private set; }
+
+ ///
+ /// Queries policy states for the resources under the management group.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given time
+ /// range, 'latest' represents the latest policy state(s), whereas 'default'
+ /// represents all policy state(s). Possible values include: 'default',
+ /// 'latest'
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyStatesResource == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyStatesResource");
+ }
+ if (managementGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string managementGroupsNamespace = "Microsoft.Management";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesResource", policyStatesResource);
+ tracingParameters.Add("managementGroupsNamespace", managementGroupsNamespace);
+ tracingParameters.Add("managementGroupName", managementGroupName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForManagementGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults").ToString();
+ _url = _url.Replace("{policyStatesResource}", System.Uri.EscapeDataString(policyStatesResource));
+ _url = _url.Replace("{managementGroupsNamespace}", System.Uri.EscapeDataString(managementGroupsNamespace));
+ _url = _url.Replace("{managementGroupName}", System.Uri.EscapeDataString(managementGroupName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Summarizes policy states for the resources under the management group.
+ ///
+ ///
+ /// Management group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> SummarizeForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (managementGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyStatesSummaryResource = "latest";
+ string managementGroupsNamespace = "Microsoft.Management";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesSummaryResource", policyStatesSummaryResource);
+ tracingParameters.Add("managementGroupsNamespace", managementGroupsNamespace);
+ tracingParameters.Add("managementGroupName", managementGroupName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SummarizeForManagementGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize").ToString();
+ _url = _url.Replace("{policyStatesSummaryResource}", System.Uri.EscapeDataString(policyStatesSummaryResource));
+ _url = _url.Replace("{managementGroupsNamespace}", System.Uri.EscapeDataString(managementGroupsNamespace));
+ _url = _url.Replace("{managementGroupName}", System.Uri.EscapeDataString(managementGroupName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy states for the resources under the subscription.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given time
+ /// range, 'latest' represents the latest policy state(s), whereas 'default'
+ /// represents all policy state(s). Possible values include: 'default',
+ /// 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyStatesResource == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyStatesResource");
+ }
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesResource", policyStatesResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscription", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults").ToString();
+ _url = _url.Replace("{policyStatesResource}", System.Uri.EscapeDataString(policyStatesResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Summarizes policy states for the resources under the subscription.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> SummarizeForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyStatesSummaryResource = "latest";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesSummaryResource", policyStatesSummaryResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SummarizeForSubscription", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize").ToString();
+ _url = _url.Replace("{policyStatesSummaryResource}", System.Uri.EscapeDataString(policyStatesSummaryResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy states for the resources under the resource group.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given time
+ /// range, 'latest' represents the latest policy state(s), whereas 'default'
+ /// represents all policy state(s). Possible values include: 'default',
+ /// 'latest'
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyStatesResource == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyStatesResource");
+ }
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (resourceGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesResource", policyStatesResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("resourceGroupName", resourceGroupName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults").ToString();
+ _url = _url.Replace("{policyStatesResource}", System.Uri.EscapeDataString(policyStatesResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Summarizes policy states for the resources under the resource group.
+ ///
+ ///
+ /// Microsoft Azure subscription ID.
+ ///
+ ///
+ /// Resource group name.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> SummarizeForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (resourceGroupName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyStatesSummaryResource = "latest";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesSummaryResource", policyStatesSummaryResource);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("resourceGroupName", resourceGroupName);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SummarizeForResourceGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize").ToString();
+ _url = _url.Replace("{policyStatesSummaryResource}", System.Uri.EscapeDataString(policyStatesSummaryResource));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Queries policy states for the resource.
+ ///
+ ///
+ /// The virtual resource under PolicyStates resource type. In a given time
+ /// range, 'latest' represents the latest policy state(s), whereas 'default'
+ /// represents all policy state(s). Possible values include: 'default',
+ /// 'latest'
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> ListQueryResultsForResourceWithHttpMessagesAsync(string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (policyStatesResource == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "policyStatesResource");
+ }
+ if (resourceId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ string orderBy = default(string);
+ if (queryOptions != null)
+ {
+ orderBy = queryOptions.OrderBy;
+ }
+ string select = default(string);
+ if (queryOptions != null)
+ {
+ select = queryOptions.Select;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ string apply = default(string);
+ if (queryOptions != null)
+ {
+ apply = queryOptions.Apply;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesResource", policyStatesResource);
+ tracingParameters.Add("resourceId", resourceId);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("orderBy", orderBy);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("apply", apply);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResource", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults").ToString();
+ _url = _url.Replace("{policyStatesResource}", System.Uri.EscapeDataString(policyStatesResource));
+ _url = _url.Replace("{resourceId}", resourceId);
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (orderBy != null)
+ {
+ _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(orderBy)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (apply != null)
+ {
+ _queryParameters.Add(string.Format("$apply={0}", System.Uri.EscapeDataString(apply)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // 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;
+ }
+
+ ///
+ /// Summarizes policy states for the resource.
+ ///
+ ///
+ /// Resource ID.
+ ///
+ ///
+ /// Additional parameters for the operation
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> SummarizeForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (resourceId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "resourceId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ string policyStatesSummaryResource = "latest";
+ int? top = default(int?);
+ if (queryOptions != null)
+ {
+ top = queryOptions.Top;
+ }
+ System.DateTime? fromParameter = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ fromParameter = queryOptions.FromProperty;
+ }
+ System.DateTime? to = default(System.DateTime?);
+ if (queryOptions != null)
+ {
+ to = queryOptions.To;
+ }
+ string filter = default(string);
+ if (queryOptions != null)
+ {
+ filter = queryOptions.Filter;
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("policyStatesSummaryResource", policyStatesSummaryResource);
+ tracingParameters.Add("resourceId", resourceId);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("to", to);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SummarizeForResource", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize").ToString();
+ _url = _url.Replace("{policyStatesSummaryResource}", System.Uri.EscapeDataString(policyStatesSummaryResource));
+ _url = _url.Replace("{resourceId}", resourceId);
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("$from={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(fromParameter, Client.SerializationSettings).Trim('"'))));
+ }
+ if (to != null)
+ {
+ _queryParameters.Add(string.Format("$to={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(to, Client.SerializationSettings).Trim('"'))));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new QueryFailureException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ QueryFailure _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse