diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs index e90994caa876..c87ff101479a 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyEventsOperations.cs @@ -47,7 +47,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the resources under the subscription. /// @@ -72,7 +72,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. /// @@ -100,7 +100,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Queries policy events for the resource. /// @@ -125,7 +125,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForResourceWithHttpMessagesAsync(string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. @@ -154,7 +154,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. /// @@ -182,7 +182,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. /// @@ -210,7 +210,7 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. @@ -242,13 +242,168 @@ public partial interface IPolicyEventsOperations /// /// 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)); + Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Gets OData metadata XML document. + /// Queries policy events for the resources under the management group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the resources under the subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the resources under the resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the subscription level policy set + /// definition. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the subscription level policy definition. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the subscription level policy assignment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy events for the resource group level policy + /// assignment. /// - /// - /// A valid scope, i.e. management group, subscription, resource group, - /// or resource ID. Scope used has no effect on metadata returned. + /// + /// The NextLink from the previous successful call to List operation. /// /// /// The headers that will be added to request. @@ -265,6 +420,6 @@ public partial interface IPolicyEventsOperations /// /// Thrown when a required parameter is null /// - Task> GetMetadataWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs index 5d9cb796ce4a..4d1f3045d543 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/IPolicyStatesOperations.cs @@ -53,7 +53,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. @@ -110,7 +110,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + 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. /// @@ -169,7 +169,7 @@ public partial interface IPolicyStatesOperations /// /// 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)); + 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. @@ -229,7 +229,7 @@ public partial interface IPolicyStatesOperations /// /// Thrown when a required parameter is null /// - Task> ListQueryResultsForResourceWithHttpMessagesAsync(string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task>> ListQueryResultsForResourceWithHttpMessagesAsync(string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Summarizes policy states for the resource. /// @@ -289,7 +289,7 @@ public partial interface IPolicyStatesOperations /// /// 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)); + 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. @@ -352,7 +352,7 @@ public partial interface IPolicyStatesOperations /// /// 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)); + 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. @@ -415,7 +415,7 @@ public partial interface IPolicyStatesOperations /// /// 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)); + 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. @@ -482,7 +482,7 @@ public partial interface IPolicyStatesOperations /// /// 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)); + 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. @@ -515,5 +515,183 @@ public partial interface IPolicyStatesOperations /// Thrown when a required parameter is null /// Task> SummarizeForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the resources under the management group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the resources under the subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the resources under the resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the resource. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the subscription level policy set + /// definition. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the subscription level policy definition. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the subscription level policy assignment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Queries policy states for the resource group level policy + /// assignment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Page1.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Page1.cs new file mode 100644 index 000000000000..b9cc3d418005 --- /dev/null +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/Page1.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.PolicyInsights.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("@odata.nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEventsQueryResults.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEventsQueryResults.cs deleted file mode 100644 index 7d194f68d0b7..000000000000 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyEventsQueryResults.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// 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/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyStatesQueryResults.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyStatesQueryResults.cs deleted file mode 100644 index f13fbeec6a42..000000000000 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/Models/PolicyStatesQueryResults.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// 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/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs index 1345262a8047..0f287438587f 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperations.cs @@ -80,7 +80,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (managementGroupName == null) { @@ -88,7 +88,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) } string policyEventsResource = "default"; string managementGroupsNamespace = "Microsoft.Management"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -272,7 +272,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -285,7 +285,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -334,14 +334,14 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + 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"); } string policyEventsResource = "default"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -523,7 +523,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -536,7 +536,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -588,7 +588,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (subscriptionId == null) { @@ -599,7 +599,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } string policyEventsResource = "default"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -783,7 +783,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -796,7 +796,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -845,14 +845,14 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + 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"); } string policyEventsResource = "default"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -1034,7 +1034,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1047,7 +1047,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1099,7 +1099,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (subscriptionId == null) { @@ -1111,7 +1111,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) } string policyEventsResource = "default"; string authorizationNamespace = "Microsoft.Authorization"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -1297,7 +1297,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1310,7 +1310,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1362,7 +1362,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (subscriptionId == null) { @@ -1374,7 +1374,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) } string policyEventsResource = "default"; string authorizationNamespace = "Microsoft.Authorization"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -1560,7 +1560,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1573,7 +1573,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1625,7 +1625,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (subscriptionId == null) { @@ -1637,7 +1637,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) } string policyEventsResource = "default"; string authorizationNamespace = "Microsoft.Authorization"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -1823,7 +1823,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1836,7 +1836,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1891,7 +1891,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (subscriptionId == null) { @@ -1907,7 +1907,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) } string policyEventsResource = "default"; string authorizationNamespace = "Microsoft.Authorization"; - string apiVersion = "2018-04-04"; + string apiVersion = "2018-07-01-preview"; int? top = default(int?); if (queryOptions != null) { @@ -2095,7 +2095,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -2108,7 +2108,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -2128,11 +2128,1018 @@ internal PolicyEventsOperations(PolicyInsightsClient client) } /// - /// Gets OData metadata XML document. + /// Queries policy events for the resources under the management group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForManagementGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicySetDefinitionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicyDefinitionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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. /// - /// - /// A valid scope, i.e. management group, subscription, resource group, or - /// resource ID. Scope used has no effect on metadata returned. + /// + /// The NextLink from the previous successful call to List operation. /// /// /// Headers that will be added to request. @@ -2155,13 +3162,12 @@ internal PolicyEventsOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetMetadataWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (scope == null) + if (nextPageLink == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); } - string apiVersion = "2018-04-04"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2169,20 +3175,182 @@ internal PolicyEventsOperations(PolicyInsightsClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("scope", scope); - tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("nextPageLink", nextPageLink); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetMetadata", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionLevelPolicyAssignmentNext", 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); + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); List _queryParameters = new List(); - if (apiVersion != null) + if (_queryParameters.Count > 0) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _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. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupLevelPolicyAssignmentNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); @@ -2190,7 +3358,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -2271,7 +3439,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -2284,7 +3452,7 @@ internal PolicyEventsOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs index 8992e8b3f09b..2103d7ebc712 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyEventsOperationsExtensions.cs @@ -33,7 +33,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForManagementGroup(this IPolicyEventsOperations operations, string managementGroupName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForManagementGroup(this IPolicyEventsOperations operations, string managementGroupName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForManagementGroupAsync(managementGroupName, queryOptions).GetAwaiter().GetResult(); } @@ -53,7 +53,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForManagementGroupAsync(this IPolicyEventsOperations operations, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -73,7 +73,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForSubscription(this IPolicyEventsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForSubscription(this IPolicyEventsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForSubscriptionAsync(subscriptionId, queryOptions).GetAwaiter().GetResult(); } @@ -93,7 +93,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForSubscriptionAsync(this IPolicyEventsOperations operations, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -116,7 +116,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForResourceGroup(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForResourceGroup(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForResourceGroupAsync(subscriptionId, resourceGroupName, queryOptions).GetAwaiter().GetResult(); } @@ -139,7 +139,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForResourceGroupAsync(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -159,7 +159,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForResource(this IPolicyEventsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForResource(this IPolicyEventsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForResourceAsync(resourceId, queryOptions).GetAwaiter().GetResult(); } @@ -179,7 +179,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForResourceAsync(this IPolicyEventsOperations operations, string resourceId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -202,7 +202,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForPolicySetDefinition(this IPolicyEventsOperations operations, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForPolicySetDefinition(this IPolicyEventsOperations operations, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForPolicySetDefinitionAsync(subscriptionId, policySetDefinitionName, queryOptions).GetAwaiter().GetResult(); } @@ -225,7 +225,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForPolicySetDefinitionAsync(this IPolicyEventsOperations operations, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -248,7 +248,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForPolicyDefinition(this IPolicyEventsOperations operations, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForPolicyDefinition(this IPolicyEventsOperations operations, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForPolicyDefinitionAsync(subscriptionId, policyDefinitionName, queryOptions).GetAwaiter().GetResult(); } @@ -271,7 +271,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForPolicyDefinitionAsync(this IPolicyEventsOperations operations, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -294,7 +294,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForSubscriptionLevelPolicyAssignment(this IPolicyEventsOperations operations, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForSubscriptionLevelPolicyAssignment(this IPolicyEventsOperations operations, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(subscriptionId, policyAssignmentName, queryOptions).GetAwaiter().GetResult(); } @@ -317,7 +317,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(this IPolicyEventsOperations operations, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + 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)) { @@ -343,7 +343,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyEventsQueryResults ListQueryResultsForResourceGroupLevelPolicyAssignment(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForResourceGroupLevelPolicyAssignment(this IPolicyEventsOperations operations, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(subscriptionId, resourceGroupName, policyAssignmentName, queryOptions).GetAwaiter().GetResult(); } @@ -369,7 +369,7 @@ public static partial class PolicyEventsOperationsExtensions /// /// 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)) + 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)) { @@ -378,36 +378,272 @@ public static partial class PolicyEventsOperationsExtensions } /// - /// Gets OData metadata XML document. + /// Queries policy events for the resources under the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForManagementGroupNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the resources under the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForManagementGroupNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy events for the resources under the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForSubscriptionNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForSubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the resources under the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForSubscriptionNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy events for the resources under the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForResourceGroupNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the resources under the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForResourceGroupNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy events for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForResourceNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForResourceNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy events for the subscription level policy set definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForPolicySetDefinitionNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForPolicySetDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the subscription level policy set definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForPolicySetDefinitionNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy events for the subscription level policy definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForPolicyDefinitionNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForPolicyDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the subscription level policy definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForPolicyDefinitionNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy events for the subscription level policy assignment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForSubscriptionLevelPolicyAssignmentNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the subscription level policy assignment. /// /// /// 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 NextLink from the previous successful call to List operation. /// - public static string GetMetadata(this IPolicyEventsOperations operations, string scope) + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - return operations.GetMetadataAsync(scope).GetAwaiter().GetResult(); + using (var _result = await operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } } /// - /// Gets OData metadata XML document. + /// Queries policy events for the resource group level policy assignment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForResourceGroupLevelPolicyAssignmentNext(this IPolicyEventsOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy events for the resource group level policy assignment. /// /// /// 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 NextLink from the previous successful call to List operation. /// /// /// The cancellation token. /// - public static async Task GetMetadataAsync(this IPolicyEventsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(this IPolicyEventsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.GetMetadataWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs index 6c6e84f47eb4..16aa048ac8a8 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperations.cs @@ -86,7 +86,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForManagementGroupWithHttpMessagesAsync(string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -281,7 +281,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -294,7 +294,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -573,7 +573,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForSubscriptionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -765,7 +765,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -778,7 +778,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1057,7 +1057,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForResourceGroupWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -1255,7 +1255,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1268,7 +1268,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1553,7 +1553,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// 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)) + public async Task>> ListQueryResultsForResourceWithHttpMessagesAsync(string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -1755,7 +1755,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1768,7 +1768,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -2047,7 +2047,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -2248,7 +2248,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -2261,7 +2261,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -2552,7 +2552,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -2753,7 +2753,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -2766,7 +2766,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -3057,7 +3057,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -3258,7 +3258,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -3271,7 +3271,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -3565,7 +3565,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (policyStatesResource == null) { @@ -3772,7 +3772,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -3785,7 +3785,7 @@ internal PolicyStatesOperations(PolicyInsightsClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -4046,5 +4046,1349 @@ internal PolicyStatesOperations(PolicyInsightsClient client) return _result; } + /// + /// Queries policy states for the resources under the management group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForManagementGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 subscription level policy set definition. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicySetDefinitionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 subscription level policy definition. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForPolicyDefinitionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 subscription level policy assignment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForSubscriptionLevelPolicyAssignmentNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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 group level policy assignment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListQueryResultsForResourceGroupLevelPolicyAssignmentNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("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; + } + } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs index f07e2a859e83..63ea9847c5c1 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/PolicyStatesOperationsExtensions.cs @@ -39,7 +39,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForManagementGroup(this IPolicyStatesOperations operations, string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForManagementGroup(this IPolicyStatesOperations operations, string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForManagementGroupAsync(policyStatesResource, managementGroupName, queryOptions).GetAwaiter().GetResult(); } @@ -65,7 +65,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForManagementGroupAsync(this IPolicyStatesOperations operations, string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForManagementGroupAsync(this IPolicyStatesOperations operations, string policyStatesResource, string managementGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForManagementGroupWithHttpMessagesAsync(policyStatesResource, managementGroupName, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -131,7 +131,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForSubscription(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForSubscription(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForSubscriptionAsync(policyStatesResource, subscriptionId, queryOptions).GetAwaiter().GetResult(); } @@ -157,7 +157,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForSubscriptionAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForSubscriptionAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForSubscriptionWithHttpMessagesAsync(policyStatesResource, subscriptionId, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -226,7 +226,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForResourceGroup(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForResourceGroup(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForResourceGroupAsync(policyStatesResource, subscriptionId, resourceGroupName, queryOptions).GetAwaiter().GetResult(); } @@ -255,7 +255,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForResourceGroupAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForResourceGroupAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForResourceGroupWithHttpMessagesAsync(policyStatesResource, subscriptionId, resourceGroupName, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -327,7 +327,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForResource(this IPolicyStatesOperations operations, string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForResource(this IPolicyStatesOperations operations, string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForResourceAsync(policyStatesResource, resourceId, queryOptions).GetAwaiter().GetResult(); } @@ -353,7 +353,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForResourceAsync(this IPolicyStatesOperations operations, string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForResourceAsync(this IPolicyStatesOperations operations, string policyStatesResource, string resourceId, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForResourceWithHttpMessagesAsync(policyStatesResource, resourceId, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -422,7 +422,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForPolicySetDefinition(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForPolicySetDefinition(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForPolicySetDefinitionAsync(policyStatesResource, subscriptionId, policySetDefinitionName, queryOptions).GetAwaiter().GetResult(); } @@ -451,7 +451,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForPolicySetDefinitionAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForPolicySetDefinitionAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policySetDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForPolicySetDefinitionWithHttpMessagesAsync(policyStatesResource, subscriptionId, policySetDefinitionName, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -526,7 +526,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForPolicyDefinition(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForPolicyDefinition(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForPolicyDefinitionAsync(policyStatesResource, subscriptionId, policyDefinitionName, queryOptions).GetAwaiter().GetResult(); } @@ -555,7 +555,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForPolicyDefinitionAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForPolicyDefinitionAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyDefinitionName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForPolicyDefinitionWithHttpMessagesAsync(policyStatesResource, subscriptionId, policyDefinitionName, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -630,7 +630,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForSubscriptionLevelPolicyAssignment(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForSubscriptionLevelPolicyAssignment(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(policyStatesResource, subscriptionId, policyAssignmentName, queryOptions).GetAwaiter().GetResult(); } @@ -659,7 +659,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentWithHttpMessagesAsync(policyStatesResource, subscriptionId, policyAssignmentName, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -737,7 +737,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// Additional parameters for the operation /// - public static PolicyStatesQueryResults ListQueryResultsForResourceGroupLevelPolicyAssignment(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) + public static IPage ListQueryResultsForResourceGroupLevelPolicyAssignment(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions)) { return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(policyStatesResource, subscriptionId, resourceGroupName, policyAssignmentName, queryOptions).GetAwaiter().GetResult(); } @@ -769,7 +769,7 @@ public static partial class PolicyStatesOperationsExtensions /// /// The cancellation token. /// - public static async Task ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(this IPolicyStatesOperations operations, string policyStatesResource, string subscriptionId, string resourceGroupName, string policyAssignmentName, QueryOptions queryOptions = default(QueryOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentWithHttpMessagesAsync(policyStatesResource, subscriptionId, resourceGroupName, policyAssignmentName, queryOptions, null, cancellationToken).ConfigureAwait(false)) { @@ -829,5 +829,277 @@ public static partial class PolicyStatesOperationsExtensions } } + /// + /// Queries policy states for the resources under the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForManagementGroupNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the resources under the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForManagementGroupNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the resources under the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForSubscriptionNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForSubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the resources under the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForSubscriptionNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForSubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the resources under the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForResourceGroupNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the resources under the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForResourceGroupNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForResourceNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForResourceNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the subscription level policy set definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForPolicySetDefinitionNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForPolicySetDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the subscription level policy set definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForPolicySetDefinitionNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForPolicySetDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the subscription level policy definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForPolicyDefinitionNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForPolicyDefinitionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the subscription level policy definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForPolicyDefinitionNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForPolicyDefinitionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the subscription level policy assignment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForSubscriptionLevelPolicyAssignmentNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the subscription level policy assignment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForSubscriptionLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Queries policy states for the resource group level policy assignment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListQueryResultsForResourceGroupLevelPolicyAssignmentNext(this IPolicyStatesOperations operations, string nextPageLink) + { + return operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Queries policy states for the resource group level policy assignment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentNextAsync(this IPolicyStatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListQueryResultsForResourceGroupLevelPolicyAssignmentNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } } diff --git a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs index 3718077dd5b0..eb181c50f66a 100644 --- a/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs +++ b/sdk/policyinsights/Microsoft.Azure.Management.PolicyInsights/src/Generated/SdkInfo_PolicyInsightsClient.cs @@ -20,7 +20,7 @@ public static IEnumerable> ApiInfo_PolicyInsightsC return new Tuple[] { new Tuple("PolicyInsights", "Operations", "2019-10-01"), - new Tuple("PolicyInsights", "PolicyEvents", "2018-04-04"), + new Tuple("PolicyInsights", "PolicyEvents", "2018-07-01-preview"), new Tuple("PolicyInsights", "PolicyMetadata", "2019-10-01"), new Tuple("PolicyInsights", "PolicyStates", "2019-10-01"), new Tuple("PolicyInsights", "PolicyTrackedResources", "2018-07-01-preview"), @@ -28,16 +28,5 @@ public static IEnumerable> ApiInfo_PolicyInsightsC }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "latest"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4407"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/policyinsights/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\\work\\apiReview\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "df4187f875393a39197055e879ddd0c2ae63e84c"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } -