diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/api/Azure.ResourceManager.PolicyInsights.netstandard2.0.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/api/Azure.ResourceManager.PolicyInsights.netstandard2.0.cs index 173ccda9d03b..3c36b52fd9ab 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/api/Azure.ResourceManager.PolicyInsights.netstandard2.0.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/api/Azure.ResourceManager.PolicyInsights.netstandard2.0.cs @@ -113,6 +113,18 @@ public static partial class PolicyInsightsExtensions public static Azure.AsyncPageable GetPolicyTrackedResourceQueryResultsAsync(this Azure.ResourceManager.ManagementGroups.ManagementGroupResource managementGroupResource, Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetPolicyTrackedResourceQueryResultsAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetPolicyTrackedResourceQueryResultsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetQueryResultsForPolicyDefinitionComponentPolicyStates(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetQueryResultsForPolicyDefinitionComponentPolicyStatesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetQueryResultsForResourceComponentPolicyStates(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetQueryResultsForResourceComponentPolicyStatesAsync(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetQueryResultsForResourceGroupComponentPolicyStates(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetQueryResultsForResourceGroupComponentPolicyStatesAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetQueryResultsForSubscriptionComponentPolicyStates(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetQueryResultsForSubscriptionComponentPolicyStatesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Pageable SummarizePolicyStates(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.PolicyStateSummaryType policyStateSummaryType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Pageable SummarizePolicyStates(this Azure.ResourceManager.ManagementGroups.ManagementGroupResource managementGroupResource, Azure.ResourceManager.PolicyInsights.Models.PolicyStateSummaryType policyStateSummaryType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Pageable SummarizePolicyStates(this Azure.ResourceManager.Resources.PolicyAssignmentResource policyAssignmentResource, Azure.ResourceManager.PolicyInsights.Models.PolicyStateSummaryType policyStateSummaryType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -264,6 +276,8 @@ protected MockablePolicyInsightsArmClient() { } public virtual Azure.AsyncPageable GetPolicyStateQueryResultsAsync(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetPolicyTrackedResourceQueryResults(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetPolicyTrackedResourceQueryResultsAsync(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueryResultsForResourceComponentPolicyStates(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueryResultsForResourceComponentPolicyStatesAsync(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable SummarizePolicyStates(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.PolicyStateSummaryType policyStateSummaryType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable SummarizePolicyStatesAsync(Azure.Core.ResourceIdentifier scope, Azure.ResourceManager.PolicyInsights.Models.PolicyStateSummaryType policyStateSummaryType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } @@ -302,6 +316,10 @@ protected MockablePolicyInsightsResourceGroupResource() { } public virtual Azure.AsyncPageable GetPolicyStateQueryResultsAsync(Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetPolicyTrackedResourceQueryResults(Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetPolicyTrackedResourceQueryResultsAsync(Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueryResultsForResourceGroupComponentPolicyStates(Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueryResultsForResourceGroupComponentPolicyStatesAsync(Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates(Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesAsync(Azure.ResourceManager.PolicyInsights.Models.ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForResourceGroupLevelPolicyAssignmentPolicyEvents(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetQueryResultsForResourceGroupLevelPolicyAssignmentPolicyEventsAsync(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForResourceGroupLevelPolicyAssignmentPolicyStates(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -344,6 +362,8 @@ protected MockablePolicyInsightsSubscriptionResource() { } public virtual Azure.AsyncPageable GetPolicyStateQueryResultsAsync(Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetPolicyTrackedResourceQueryResults(Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetPolicyTrackedResourceQueryResultsAsync(Azure.ResourceManager.PolicyInsights.Models.PolicyTrackedResourceType policyTrackedResourceType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueryResultsForPolicyDefinitionComponentPolicyStates(Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueryResultsForPolicyDefinitionComponentPolicyStatesAsync(Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForPolicyDefinitionPolicyEvents(string policyDefinitionName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetQueryResultsForPolicyDefinitionPolicyEventsAsync(string policyDefinitionName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForPolicyDefinitionPolicyStates(string policyDefinitionName, Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -352,6 +372,10 @@ protected MockablePolicyInsightsSubscriptionResource() { } public virtual Azure.AsyncPageable GetQueryResultsForPolicySetDefinitionPolicyEventsAsync(string policySetDefinitionName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForPolicySetDefinitionPolicyStates(string policySetDefinitionName, Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetQueryResultsForPolicySetDefinitionPolicyStatesAsync(string policySetDefinitionName, Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueryResultsForSubscriptionComponentPolicyStates(Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueryResultsForSubscriptionComponentPolicyStatesAsync(Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates(Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesAsync(Azure.ResourceManager.PolicyInsights.Models.SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForSubscriptionLevelPolicyAssignmentPolicyEvents(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetQueryResultsForSubscriptionLevelPolicyAssignmentPolicyEventsAsync(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.PolicyEventType policyEventType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetQueryResultsForSubscriptionLevelPolicyAssignmentPolicyStates(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.PolicyStateType policyStateType, Azure.ResourceManager.PolicyInsights.Models.PolicyQuerySettings policyQuerySettings = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -392,6 +416,9 @@ public static partial class ArmPolicyInsightsModelFactory public static Azure.ResourceManager.PolicyInsights.Models.CheckRestrictionsResourceDetails CheckRestrictionsResourceDetails(System.BinaryData resourceContent = null, string apiVersion = null, string scope = null) { throw null; } public static Azure.ResourceManager.PolicyInsights.Models.ComplianceDetail ComplianceDetail(string complianceState = null, int? count = default(int?)) { throw null; } public static Azure.ResourceManager.PolicyInsights.Models.ComponentEventDetails ComponentEventDetails(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.DateTimeOffset? timestamp = default(System.DateTimeOffset?), System.Guid? tenantId = default(System.Guid?), string principalOid = null, string policyDefinitionAction = null, System.Collections.Generic.IReadOnlyDictionary additionalProperties = null) { throw null; } + public static Azure.ResourceManager.PolicyInsights.Models.ComponentExpressionEvaluationDetails ComponentExpressionEvaluationDetails(string result = null, string expression = null, string expressionKind = null, string path = null, System.BinaryData expressionValue = null, System.BinaryData targetValue = null, string @operator = null) { throw null; } + public static Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyEvaluationDetails ComponentPolicyEvaluationDetails(System.Collections.Generic.IEnumerable evaluatedExpressions = null, string reason = null) { throw null; } + public static Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyState ComponentPolicyState(string odataId = null, string odataContext = null, System.DateTimeOffset? timestamp = default(System.DateTimeOffset?), string componentId = null, string componentType = null, string componentName = null, string resourceId = null, string policyAssignmentId = null, string policyDefinitionId = null, string subscriptionId = null, string resourceType = null, string resourceLocation = null, string resourceGroup = null, string policyAssignmentName = null, string policyAssignmentOwner = null, string policyAssignmentParameters = null, string policyAssignmentScope = null, string policyDefinitionName = null, string policyDefinitionAction = null, string policyDefinitionCategory = null, string policySetDefinitionId = null, string policySetDefinitionName = null, string policySetDefinitionOwner = null, string policySetDefinitionCategory = null, string policySetDefinitionParameters = null, string policyDefinitionReferenceId = null, string complianceState = null, Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyEvaluationDetails policyEvaluationDetails = null, System.Collections.Generic.IEnumerable policyDefinitionGroupNames = null, string policyDefinitionVersion = null, string policySetDefinitionVersion = null, string policyAssignmentVersion = null, System.Collections.Generic.IReadOnlyDictionary additionalProperties = null) { throw null; } public static Azure.ResourceManager.PolicyInsights.Models.ComponentStateDetails ComponentStateDetails(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.DateTimeOffset? timestamp = default(System.DateTimeOffset?), string complianceState = null, System.Collections.Generic.IReadOnlyDictionary additionalProperties = null) { throw null; } public static Azure.ResourceManager.PolicyInsights.Models.ExpressionEvaluationDetails ExpressionEvaluationDetails(string result = null, string expression = null, string expressionKind = null, string path = null, System.BinaryData expressionValue = null, System.BinaryData targetValue = null, string @operator = null) { throw null; } public static Azure.ResourceManager.PolicyInsights.Models.FieldRestriction FieldRestriction(Azure.ResourceManager.PolicyInsights.Models.FieldRestrictionResult? result = default(Azure.ResourceManager.PolicyInsights.Models.FieldRestrictionResult?), string defaultValue = null, System.Collections.Generic.IEnumerable values = null, Azure.ResourceManager.PolicyInsights.Models.PolicyReference policy = null) { throw null; } @@ -418,6 +445,19 @@ public static partial class ArmPolicyInsightsModelFactory public static Azure.ResourceManager.PolicyInsights.Models.SlimPolicyMetadata SlimPolicyMetadata(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string metadataId = null, string category = null, string title = null, string owner = null, System.Uri additionalContentUri = null, System.BinaryData metadata = null) { throw null; } public static Azure.ResourceManager.PolicyInsights.Models.TrackedResourceModificationDetails TrackedResourceModificationDetails(Azure.ResourceManager.PolicyInsights.Models.PolicyDetails policyDetails = null, Azure.Core.ResourceIdentifier deploymentId = null, System.DateTimeOffset? deploymentOn = default(System.DateTimeOffset?)) { throw null; } } + public partial class ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions + { + public ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions(Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource componentPolicyStatesResource) { } + public string Apply { get { throw null; } set { } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource ComponentPolicyStatesResource { get { throw null; } } + public string Expand { get { throw null; } set { } } + public string Filter { get { throw null; } set { } } + public System.DateTimeOffset? From { get { throw null; } set { } } + public string OrderBy { get { throw null; } set { } } + public string Select { get { throw null; } set { } } + public System.DateTimeOffset? To { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } public partial class AttestationEvidence : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AttestationEvidence() { } @@ -506,6 +546,95 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class ComponentExpressionEvaluationDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ComponentExpressionEvaluationDetails() { } + public string Expression { get { throw null; } } + public string ExpressionKind { get { throw null; } } + public System.BinaryData ExpressionValue { get { throw null; } } + public string Operator { get { throw null; } } + public string Path { get { throw null; } } + public string Result { get { throw null; } } + public System.BinaryData TargetValue { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.PolicyInsights.Models.ComponentExpressionEvaluationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.PolicyInsights.Models.ComponentExpressionEvaluationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ComponentPolicyEvaluationDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ComponentPolicyEvaluationDetails() { } + public System.Collections.Generic.IReadOnlyList EvaluatedExpressions { get { throw null; } } + public string Reason { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyEvaluationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyEvaluationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ComponentPolicyState : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ComponentPolicyState() { } + public System.Collections.Generic.IReadOnlyDictionary AdditionalProperties { get { throw null; } } + public string ComplianceState { get { throw null; } } + public string ComponentId { get { throw null; } } + public string ComponentName { get { throw null; } } + public string ComponentType { get { throw null; } } + public string ODataContext { get { throw null; } } + public string ODataId { get { throw null; } } + public string PolicyAssignmentId { get { throw null; } } + public string PolicyAssignmentName { get { throw null; } } + public string PolicyAssignmentOwner { get { throw null; } } + public string PolicyAssignmentParameters { get { throw null; } } + public string PolicyAssignmentScope { get { throw null; } } + public string PolicyAssignmentVersion { get { throw null; } } + public string PolicyDefinitionAction { get { throw null; } } + public string PolicyDefinitionCategory { get { throw null; } } + public System.Collections.Generic.IReadOnlyList PolicyDefinitionGroupNames { get { throw null; } } + public string PolicyDefinitionId { get { throw null; } } + public string PolicyDefinitionName { get { throw null; } } + public string PolicyDefinitionReferenceId { get { throw null; } } + public string PolicyDefinitionVersion { get { throw null; } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyEvaluationDetails PolicyEvaluationDetails { get { throw null; } } + public string PolicySetDefinitionCategory { get { throw null; } } + public string PolicySetDefinitionId { get { throw null; } } + public string PolicySetDefinitionName { get { throw null; } } + public string PolicySetDefinitionOwner { get { throw null; } } + public string PolicySetDefinitionParameters { get { throw null; } } + public string PolicySetDefinitionVersion { get { throw null; } } + public string ResourceGroup { get { throw null; } } + public string ResourceId { get { throw null; } } + public string ResourceLocation { get { throw null; } } + public string ResourceType { get { throw null; } } + public string SubscriptionId { get { throw null; } } + public System.DateTimeOffset? Timestamp { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyState System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyState System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ComponentPolicyStatesResource : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ComponentPolicyStatesResource(string value) { throw null; } + public static Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource Latest { get { throw null; } } + public bool Equals(Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource left, Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource right) { throw null; } + public static implicit operator Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource left, Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource right) { throw null; } + public override string ToString() { throw null; } + } public partial class ComponentStateDetails : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ComponentStateDetails() { } @@ -983,6 +1112,31 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.ResourceManager.PolicyInsights.Models.ResourceDiscoveryMode left, Azure.ResourceManager.PolicyInsights.Models.ResourceDiscoveryMode right) { throw null; } public override string ToString() { throw null; } } + public partial class ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions + { + public ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions(Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource componentPolicyStatesResource) { } + public string Apply { get { throw null; } set { } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource ComponentPolicyStatesResource { get { throw null; } } + public string Filter { get { throw null; } set { } } + public System.DateTimeOffset? From { get { throw null; } set { } } + public string OrderBy { get { throw null; } set { } } + public string Select { get { throw null; } set { } } + public System.DateTimeOffset? To { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } + public partial class ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions + { + public ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource componentPolicyStatesResource) { } + public string Apply { get { throw null; } set { } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource ComponentPolicyStatesResource { get { throw null; } } + public string Filter { get { throw null; } set { } } + public System.DateTimeOffset? From { get { throw null; } set { } } + public string OrderBy { get { throw null; } set { } } + public string PolicyAssignmentName { get { throw null; } } + public string Select { get { throw null; } set { } } + public System.DateTimeOffset? To { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } public partial class SlimPolicyMetadata : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SlimPolicyMetadata() { } @@ -999,6 +1153,44 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions + { + public SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions(string policyDefinitionName, Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource componentPolicyStatesResource) { } + public string Apply { get { throw null; } set { } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource ComponentPolicyStatesResource { get { throw null; } } + public string Filter { get { throw null; } set { } } + public System.DateTimeOffset? From { get { throw null; } set { } } + public string OrderBy { get { throw null; } set { } } + public string PolicyDefinitionName { get { throw null; } } + public string Select { get { throw null; } set { } } + public System.DateTimeOffset? To { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } + public partial class SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions + { + public SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions(Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource componentPolicyStatesResource) { } + public string Apply { get { throw null; } set { } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource ComponentPolicyStatesResource { get { throw null; } } + public string Filter { get { throw null; } set { } } + public System.DateTimeOffset? From { get { throw null; } set { } } + public string OrderBy { get { throw null; } set { } } + public string Select { get { throw null; } set { } } + public System.DateTimeOffset? To { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } + public partial class SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions + { + public SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions(string policyAssignmentName, Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource componentPolicyStatesResource) { } + public string Apply { get { throw null; } set { } } + public Azure.ResourceManager.PolicyInsights.Models.ComponentPolicyStatesResource ComponentPolicyStatesResource { get { throw null; } } + public string Filter { get { throw null; } set { } } + public System.DateTimeOffset? From { get { throw null; } set { } } + public string OrderBy { get { throw null; } set { } } + public string PolicyAssignmentName { get { throw null; } } + public string Select { get { throw null; } set { } } + public System.DateTimeOffset? To { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } public partial class TrackedResourceModificationDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TrackedResourceModificationDetails() { } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 9c6e3e1670cf..0c3be636829a 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -307,5 +307,95 @@ public async Task CheckPolicyRestrictions_CheckPolicyRestrictionsAtResourceGroup Console.WriteLine($"Succeeded: {result}"); } + + // Query latest component policy compliance state count grouped by component type at resource group scope filtered by given assignment. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForResourceGroupComponentPolicyStates_QueryLatestComponentPolicyComplianceStateCountGroupedByComponentTypeAtResourceGroupScopeFilteredByGivenAssignment() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceGroupScopeGroupByComponentTypeWithAggregate.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "fffedd8f-ffff-fffd-fffd-fffed2f84852"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options = new ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions(componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { Filter = "policyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8'", Apply = "groupby((type,complianceState),aggregate($count as count))" }; + await foreach (ComponentPolicyState item in resourceGroupResource.GetQueryResultsForResourceGroupComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Query latest component policy states at resource group scope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForResourceGroupComponentPolicyStates_QueryLatestComponentPolicyStatesAtResourceGroupScope() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceGroupScope.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "fffedd8f-ffff-fffd-fffd-fffed2f84852"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options = new ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions(componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { }; + await foreach (ComponentPolicyState item in resourceGroupResource.GetQueryResultsForResourceGroupComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Query latest at resource group level policy assignment scope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates_QueryLatestAtResourceGroupLevelPolicyAssignmentScope() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForResourceGroupLevelPolicyAssignment" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "fffedd8f-ffff-fffd-fffd-fffed2f84852"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options = new ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions(policyAssignmentName: "myPolicyAssignment", componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { }; + await foreach (ComponentPolicyState item in resourceGroupResource.GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } } } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index cc6722b584b1..2778f2a73292 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -617,5 +617,121 @@ public async Task CheckPolicyRestrictions_CheckPolicyRestrictionsAtSubscriptionS Console.WriteLine($"Succeeded: {result}"); } + + // Query latest component policy compliance state count grouped by component type at subscription scope filtered by given assignment. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForSubscriptionComponentPolicyStates_QueryLatestComponentPolicyComplianceStateCountGroupedByComponentTypeAtSubscriptionScopeFilteredByGivenAssignment() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionScopeGroupByComponentTypeWithAggregate.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForSubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "e78961ba-36fe-4739-9212-e3031b4c8db7"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options = new SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions(componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { Filter = "policyAssignmentId eq '/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8'", Apply = "groupby((componentType,complianceState),aggregate($count as count))" }; + await foreach (ComponentPolicyState item in subscriptionResource.GetQueryResultsForSubscriptionComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Query latest component policy states at subscription scope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForSubscriptionComponentPolicyStates_QueryLatestComponentPolicyStatesAtSubscriptionScope() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionScope.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForSubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fff10b27-fff3-fff5-fff8-fffbe01e86a5"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options = new SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions(componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { }; + await foreach (ComponentPolicyState item in subscriptionResource.GetQueryResultsForSubscriptionComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Query latest component policy states at subscription level policy definition scope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForPolicyDefinitionComponentPolicyStates_QueryLatestComponentPolicyStatesAtSubscriptionLevelPolicyDefinitionScope() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForPolicyDefinition" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fffedd8f-ffff-fffd-fffd-fffed2f84852"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options = new SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions(policyDefinitionName: "24813039-7534-408a-9842-eb99f45721b1", componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { }; + await foreach (ComponentPolicyState item in subscriptionResource.GetQueryResultsForPolicyDefinitionComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Query latest at subscription level policy assignment scope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates_QueryLatestAtSubscriptionLevelPolicyAssignmentScope() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json + // this example is just showing the usage of "ComponentPolicyStates_ListQueryResultsForSubscriptionLevelPolicyAssignment" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fffedd8f-ffff-fffd-fffd-fffed2f84852"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options = new SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions(policyAssignmentName: "ec8f9645-8ecb-4abb-9c0b-5292f19d4003", componentPolicyStatesResource: ComponentPolicyStatesResource.Latest) { }; + await foreach (ComponentPolicyState item in subscriptionResource.GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } } } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/ArmPolicyInsightsModelFactory.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/ArmPolicyInsightsModelFactory.cs index a4acf8d01c07..fcefa1cd12ff 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/ArmPolicyInsightsModelFactory.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/ArmPolicyInsightsModelFactory.cs @@ -94,7 +94,7 @@ public static RemediationDeployment RemediationDeployment(ResourceIdentifier rem /// The resource ID of the policy assignment that should be remediated. /// The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition. /// The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified. - /// The status of the remediation. + /// The status of the remediation. This refers to the entire remediation task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, Complete, or Succeeded. /// The time at which the remediation was created. /// The time at which the remediation was last updated. /// The filters that will be applied to determine which resources to remediate. @@ -632,6 +632,115 @@ public static PolicyEvaluationResult PolicyEvaluationResult(PolicyReference poli return new PolicyEvaluationResult(policyInfo, evaluationResult, evaluationDetails, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// OData entity ID; always set to null since component policy state records do not have an entity ID. + /// OData context string; used by OData clients to resolve type information based on metadata. + /// Timestamp for the component policy state record. + /// Component Id. + /// Component type. + /// Component name. + /// Resource ID. + /// Policy assignment ID. + /// Policy definition ID. + /// Subscription ID. + /// Resource type. + /// Resource location. + /// Resource group name. + /// Policy assignment name. + /// Policy assignment owner. + /// Policy assignment parameters. + /// Policy assignment scope. + /// Policy definition name. + /// Policy definition action, i.e. effect. + /// Policy definition category. + /// Policy set definition ID, if the policy assignment is for a policy set. + /// Policy set definition name, if the policy assignment is for a policy set. + /// Policy set definition owner, if the policy assignment is for a policy set. + /// Policy set definition category, if the policy assignment is for a policy set. + /// Policy set definition parameters, if the policy assignment is for a policy set. + /// Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. + /// Compliance state of the resource. + /// Policy evaluation details. This is only included in the response if the request contains $expand=PolicyEvaluationDetails. + /// Policy definition group names. + /// Evaluated policy definition version. + /// Evaluated policy set definition version. + /// Evaluated policy assignment version. + /// Additional Properties. + /// A new instance for mocking. + public static ComponentPolicyState ComponentPolicyState(string odataId = null, string odataContext = null, DateTimeOffset? timestamp = null, string componentId = null, string componentType = null, string componentName = null, string resourceId = null, string policyAssignmentId = null, string policyDefinitionId = null, string subscriptionId = null, string resourceType = null, string resourceLocation = null, string resourceGroup = null, string policyAssignmentName = null, string policyAssignmentOwner = null, string policyAssignmentParameters = null, string policyAssignmentScope = null, string policyDefinitionName = null, string policyDefinitionAction = null, string policyDefinitionCategory = null, string policySetDefinitionId = null, string policySetDefinitionName = null, string policySetDefinitionOwner = null, string policySetDefinitionCategory = null, string policySetDefinitionParameters = null, string policyDefinitionReferenceId = null, string complianceState = null, ComponentPolicyEvaluationDetails policyEvaluationDetails = null, IEnumerable policyDefinitionGroupNames = null, string policyDefinitionVersion = null, string policySetDefinitionVersion = null, string policyAssignmentVersion = null, IReadOnlyDictionary additionalProperties = null) + { + policyDefinitionGroupNames ??= new List(); + additionalProperties ??= new Dictionary(); + + return new ComponentPolicyState( + odataId, + odataContext, + timestamp, + componentId, + componentType, + componentName, + resourceId, + policyAssignmentId, + policyDefinitionId, + subscriptionId, + resourceType, + resourceLocation, + resourceGroup, + policyAssignmentName, + policyAssignmentOwner, + policyAssignmentParameters, + policyAssignmentScope, + policyDefinitionName, + policyDefinitionAction, + policyDefinitionCategory, + policySetDefinitionId, + policySetDefinitionName, + policySetDefinitionOwner, + policySetDefinitionCategory, + policySetDefinitionParameters, + policyDefinitionReferenceId, + complianceState, + policyEvaluationDetails, + policyDefinitionGroupNames?.ToList(), + policyDefinitionVersion, + policySetDefinitionVersion, + policyAssignmentVersion, + additionalProperties); + } + + /// Initializes a new instance of . + /// Details of the evaluated expressions. + /// Additional textual reason for the evaluation outcome. + /// A new instance for mocking. + public static ComponentPolicyEvaluationDetails ComponentPolicyEvaluationDetails(IEnumerable evaluatedExpressions = null, string reason = null) + { + evaluatedExpressions ??= new List(); + + return new ComponentPolicyEvaluationDetails(evaluatedExpressions?.ToList(), reason, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Evaluation result. + /// Expression evaluated. + /// The kind of expression that was evaluated. + /// Property path if the expression is a field or an alias. + /// Value of the expression. + /// Target value to be compared with the expression value. + /// Operator to compare the expression value and the target value. + /// A new instance for mocking. + public static ComponentExpressionEvaluationDetails ComponentExpressionEvaluationDetails(string result = null, string expression = null, string expressionKind = null, string path = null, BinaryData expressionValue = null, BinaryData targetValue = null, string @operator = null) + { + return new ComponentExpressionEvaluationDetails( + result, + expression, + expressionKind, + path, + expressionValue, + targetValue, + @operator, + serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The id. /// The name. diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsArmClient.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsArmClient.cs index 6f01935273d2..85748c5ebfef 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsArmClient.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsArmClient.cs @@ -24,6 +24,8 @@ public partial class MockablePolicyInsightsArmClient : ArmResource private PolicyEventsRestOperations _policyEventsRestClient; private ClientDiagnostics _policyStatesClientDiagnostics; private PolicyStatesRestOperations _policyStatesRestClient; + private ClientDiagnostics _componentPolicyStatesClientDiagnostics; + private ComponentPolicyStatesRestOperations _componentPolicyStatesRestClient; /// Initializes a new instance of the class for mocking. protected MockablePolicyInsightsArmClient() @@ -47,6 +49,8 @@ internal MockablePolicyInsightsArmClient(ArmClient client) : this(client, Resour private PolicyEventsRestOperations PolicyEventsRestClient => _policyEventsRestClient ??= new PolicyEventsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics PolicyStatesClientDiagnostics => _policyStatesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.PolicyInsights", ProviderConstants.DefaultProviderNamespace, Diagnostics); private PolicyStatesRestOperations PolicyStatesRestClient => _policyStatesRestClient ??= new PolicyStatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics ComponentPolicyStatesClientDiagnostics => _componentPolicyStatesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.PolicyInsights", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private ComponentPolicyStatesRestOperations ComponentPolicyStatesRestClient => _componentPolicyStatesRestClient ??= new ComponentPolicyStatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private string GetApiVersionOrNull(ResourceType resourceType) { @@ -451,6 +455,68 @@ public virtual Pageable SummarizePolicyStates(ResourceIdentifier HttpMessage FirstPageRequest(int? pageSizeHint) => PolicyStatesRestClient.CreateSummarizeForResourceRequest(scope, policyStateSummaryType, policyQuerySettings); return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => PolicySummary.DeserializePolicySummary(e), PolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsArmClient.SummarizePolicyStates", "value", null, cancellationToken); } + + /// + /// Queries component policy states for the resource. + /// + /// + /// Request Path + /// /{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResource + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// The scope that the resource will apply against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetQueryResultsForResourceComponentPolicyStatesAsync(ResourceIdentifier scope, ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(scope, nameof(scope)); + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForResourceRequest(scope, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply, options.Expand); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsArmClient.GetQueryResultsForResourceComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the resource. + /// + /// + /// Request Path + /// /{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResource + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// The scope that the resource will apply against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetQueryResultsForResourceComponentPolicyStates(ResourceIdentifier scope, ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(scope, nameof(scope)); + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForResourceRequest(scope, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply, options.Expand); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsArmClient.GetQueryResultsForResourceComponentPolicyStates", "value", null, cancellationToken); + } /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// You can use to create a from its components. diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsResourceGroupResource.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsResourceGroupResource.cs index 660066cc8d4b..f2a05911981c 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsResourceGroupResource.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsResourceGroupResource.cs @@ -26,6 +26,8 @@ public partial class MockablePolicyInsightsResourceGroupResource : ArmResource private PolicyStatesRestOperations _policyStatesRestClient; private ClientDiagnostics _policyRestrictionsClientDiagnostics; private PolicyRestrictionsRestOperations _policyRestrictionsRestClient; + private ClientDiagnostics _componentPolicyStatesClientDiagnostics; + private ComponentPolicyStatesRestOperations _componentPolicyStatesRestClient; /// Initializes a new instance of the class for mocking. protected MockablePolicyInsightsResourceGroupResource() @@ -47,6 +49,8 @@ internal MockablePolicyInsightsResourceGroupResource(ArmClient client, ResourceI private PolicyStatesRestOperations PolicyStatesRestClient => _policyStatesRestClient ??= new PolicyStatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics PolicyRestrictionsClientDiagnostics => _policyRestrictionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.PolicyInsights", ProviderConstants.DefaultProviderNamespace, Diagnostics); private PolicyRestrictionsRestOperations PolicyRestrictionsRestClient => _policyRestrictionsRestClient ??= new PolicyRestrictionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics ComponentPolicyStatesClientDiagnostics => _componentPolicyStatesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.PolicyInsights", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private ComponentPolicyStatesRestOperations ComponentPolicyStatesRestClient => _componentPolicyStatesRestClient ??= new ComponentPolicyStatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private string GetApiVersionOrNull(ResourceType resourceType) { @@ -623,5 +627,121 @@ public virtual Response CheckPolicyRestrictions(C throw; } } + + /// + /// Queries component policy states under resource group scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroup + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetQueryResultsForResourceGroupComponentPolicyStatesAsync(ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsResourceGroupResource.GetQueryResultsForResourceGroupComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states under resource group scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroup + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetQueryResultsForResourceGroupComponentPolicyStates(ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsResourceGroupResource.GetQueryResultsForResourceGroupComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the resource group level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroupLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesAsync(ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForResourceGroupLevelPolicyAssignmentRequest(Id.SubscriptionId, Id.ResourceGroupName, options.PolicyAssignmentName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsResourceGroupResource.GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the resource group level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroupLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates(ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForResourceGroupLevelPolicyAssignmentRequest(Id.SubscriptionId, Id.ResourceGroupName, options.PolicyAssignmentName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsResourceGroupResource.GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates", "value", null, cancellationToken); + } } } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsSubscriptionResource.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsSubscriptionResource.cs index d1c68036af3c..693c826d942f 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsSubscriptionResource.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/MockablePolicyInsightsSubscriptionResource.cs @@ -26,6 +26,8 @@ public partial class MockablePolicyInsightsSubscriptionResource : ArmResource private PolicyStatesRestOperations _policyStatesRestClient; private ClientDiagnostics _policyRestrictionsClientDiagnostics; private PolicyRestrictionsRestOperations _policyRestrictionsRestClient; + private ClientDiagnostics _componentPolicyStatesClientDiagnostics; + private ComponentPolicyStatesRestOperations _componentPolicyStatesRestClient; /// Initializes a new instance of the class for mocking. protected MockablePolicyInsightsSubscriptionResource() @@ -47,6 +49,8 @@ internal MockablePolicyInsightsSubscriptionResource(ArmClient client, ResourceId private PolicyStatesRestOperations PolicyStatesRestClient => _policyStatesRestClient ??= new PolicyStatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics PolicyRestrictionsClientDiagnostics => _policyRestrictionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.PolicyInsights", ProviderConstants.DefaultProviderNamespace, Diagnostics); private PolicyRestrictionsRestOperations PolicyRestrictionsRestClient => _policyRestrictionsRestClient ??= new PolicyRestrictionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics ComponentPolicyStatesClientDiagnostics => _componentPolicyStatesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.PolicyInsights", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private ComponentPolicyStatesRestOperations ComponentPolicyStatesRestClient => _componentPolicyStatesRestClient ??= new ComponentPolicyStatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private string GetApiVersionOrNull(ResourceType resourceType) { @@ -1015,5 +1019,179 @@ public virtual Response CheckPolicyRestrictions(C throw; } } + + /// + /// Queries component policy states under subscription scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscription + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetQueryResultsForSubscriptionComponentPolicyStatesAsync(SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForSubscriptionRequest(Id.SubscriptionId, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsSubscriptionResource.GetQueryResultsForSubscriptionComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states under subscription scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscription + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetQueryResultsForSubscriptionComponentPolicyStates(SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForSubscriptionRequest(Id.SubscriptionId, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsSubscriptionResource.GetQueryResultsForSubscriptionComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy definition. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForPolicyDefinition + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetQueryResultsForPolicyDefinitionComponentPolicyStatesAsync(SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForPolicyDefinitionRequest(Id.SubscriptionId, options.PolicyDefinitionName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsSubscriptionResource.GetQueryResultsForPolicyDefinitionComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy definition. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForPolicyDefinition + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetQueryResultsForPolicyDefinitionComponentPolicyStates(SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForPolicyDefinitionRequest(Id.SubscriptionId, options.PolicyDefinitionName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsSubscriptionResource.GetQueryResultsForPolicyDefinitionComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscriptionLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesAsync(SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForSubscriptionLevelPolicyAssignmentRequest(Id.SubscriptionId, options.PolicyAssignmentName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsSubscriptionResource.GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates", "value", null, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscriptionLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates(SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(options, nameof(options)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ComponentPolicyStatesRestClient.CreateListQueryResultsForSubscriptionLevelPolicyAssignmentRequest(Id.SubscriptionId, options.PolicyAssignmentName, options.ComponentPolicyStatesResource, options.Top, options.OrderBy, options.Select, options.From, options.To, options.Filter, options.Apply); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => ComponentPolicyState.DeserializeComponentPolicyState(e), ComponentPolicyStatesClientDiagnostics, Pipeline, "MockablePolicyInsightsSubscriptionResource.GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates", "value", null, cancellationToken); + } } } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/PolicyInsightsExtensions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/PolicyInsightsExtensions.cs index 33fbe92566ed..cf50e518f863 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/PolicyInsightsExtensions.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Extensions/PolicyInsightsExtensions.cs @@ -508,6 +508,72 @@ public static Pageable SummarizePolicyStates(this ArmClient clien return GetMockablePolicyInsightsArmClient(client).SummarizePolicyStates(scope, policyStateSummaryType, policyQuerySettings, cancellationToken); } + /// + /// Queries component policy states for the resource. + /// + /// + /// Request Path + /// /{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResource + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + public static AsyncPageable GetQueryResultsForResourceComponentPolicyStatesAsync(this ArmClient client, ResourceIdentifier scope, ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockablePolicyInsightsArmClient(client).GetQueryResultsForResourceComponentPolicyStatesAsync(scope, options, cancellationToken); + } + + /// + /// Queries component policy states for the resource. + /// + /// + /// Request Path + /// /{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResource + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + public static Pageable GetQueryResultsForResourceComponentPolicyStates(this ArmClient client, ResourceIdentifier scope, ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockablePolicyInsightsArmClient(client).GetQueryResultsForResourceComponentPolicyStates(scope, options, cancellationToken); + } + /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// You can use to create a from its components. @@ -1301,6 +1367,138 @@ public static Response CheckPolicyRestrictions(th return GetMockablePolicyInsightsResourceGroupResource(resourceGroupResource).CheckPolicyRestrictions(content, cancellationToken); } + /// + /// Queries component policy states under resource group scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroup + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetQueryResultsForResourceGroupComponentPolicyStatesAsync(this ResourceGroupResource resourceGroupResource, ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockablePolicyInsightsResourceGroupResource(resourceGroupResource).GetQueryResultsForResourceGroupComponentPolicyStatesAsync(options, cancellationToken); + } + + /// + /// Queries component policy states under resource group scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroup + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetQueryResultsForResourceGroupComponentPolicyStates(this ResourceGroupResource resourceGroupResource, ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockablePolicyInsightsResourceGroupResource(resourceGroupResource).GetQueryResultsForResourceGroupComponentPolicyStates(options, cancellationToken); + } + + /// + /// Queries component policy states for the resource group level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroupLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesAsync(this ResourceGroupResource resourceGroupResource, ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockablePolicyInsightsResourceGroupResource(resourceGroupResource).GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesAsync(options, cancellationToken); + } + + /// + /// Queries component policy states for the resource group level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForResourceGroupLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates(this ResourceGroupResource resourceGroupResource, ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockablePolicyInsightsResourceGroupResource(resourceGroupResource).GetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStates(options, cancellationToken); + } + /// /// Queries policy tracked resources under the subscription. /// @@ -1701,6 +1899,204 @@ public static Response CheckPolicyRestrictions(th return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).CheckPolicyRestrictions(content, cancellationToken); } + /// + /// Queries component policy states under subscription scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscription + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetQueryResultsForSubscriptionComponentPolicyStatesAsync(this SubscriptionResource subscriptionResource, SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).GetQueryResultsForSubscriptionComponentPolicyStatesAsync(options, cancellationToken); + } + + /// + /// Queries component policy states under subscription scope. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscription + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetQueryResultsForSubscriptionComponentPolicyStates(this SubscriptionResource subscriptionResource, SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).GetQueryResultsForSubscriptionComponentPolicyStates(options, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy definition. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForPolicyDefinition + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetQueryResultsForPolicyDefinitionComponentPolicyStatesAsync(this SubscriptionResource subscriptionResource, SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).GetQueryResultsForPolicyDefinitionComponentPolicyStatesAsync(options, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy definition. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForPolicyDefinition + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetQueryResultsForPolicyDefinitionComponentPolicyStates(this SubscriptionResource subscriptionResource, SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).GetQueryResultsForPolicyDefinitionComponentPolicyStates(options, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscriptionLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesAsync(this SubscriptionResource subscriptionResource, SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesAsync(options, cancellationToken); + } + + /// + /// Queries component policy states for the subscription level policy assignment. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults + /// + /// + /// Operation Id + /// ComponentPolicyStates_ListQueryResultsForSubscriptionLevelPolicyAssignment + /// + /// + /// Default Api Version + /// 2022-04-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates(this SubscriptionResource subscriptionResource, SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockablePolicyInsightsSubscriptionResource(subscriptionResource).GetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStates(options, cancellationToken); + } + /// /// Gets a collection of PolicyMetadataResources in the TenantResource. /// diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions.cs new file mode 100644 index 000000000000..73bb2bb5ad02 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions. + public partial class ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions + { + /// Initializes a new instance of . + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions(ComponentPolicyStatesResource componentPolicyStatesResource) + { + ComponentPolicyStatesResource = componentPolicyStatesResource; + } + + /// Initializes a new instance of for deserialization. + internal ArmResourceGetQueryResultsForResourceComponentPolicyStatesOptions() + { + } + + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ComponentPolicyStatesResource ComponentPolicyStatesResource { get; } + /// Maximum number of records to return. + public int? Top { get; set; } + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + public string OrderBy { get; set; } + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + public string Select { get; set; } + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + public DateTimeOffset? From { get; set; } + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + public DateTimeOffset? To { get; set; } + /// OData filter expression. + public string Filter { get; set; } + /// OData apply expression for aggregations. + public string Apply { get; set; } + /// The $expand query parameter. + public string Expand { get; set; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentExpressionEvaluationDetails.Serialization.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentExpressionEvaluationDetails.Serialization.cs new file mode 100644 index 000000000000..9d51f35d3471 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentExpressionEvaluationDetails.Serialization.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + public partial class ComponentExpressionEvaluationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentExpressionEvaluationDetails)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result); + } + if (options.Format != "W" && Optional.IsDefined(Expression)) + { + writer.WritePropertyName("expression"u8); + writer.WriteStringValue(Expression); + } + if (options.Format != "W" && Optional.IsDefined(ExpressionKind)) + { + writer.WritePropertyName("expressionKind"u8); + writer.WriteStringValue(ExpressionKind); + } + if (options.Format != "W" && Optional.IsDefined(Path)) + { + writer.WritePropertyName("path"u8); + writer.WriteStringValue(Path); + } + if (options.Format != "W" && Optional.IsDefined(ExpressionValue)) + { + writer.WritePropertyName("expressionValue"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ExpressionValue); +#else + using (JsonDocument document = JsonDocument.Parse(ExpressionValue)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (options.Format != "W" && Optional.IsDefined(TargetValue)) + { + writer.WritePropertyName("targetValue"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(TargetValue); +#else + using (JsonDocument document = JsonDocument.Parse(TargetValue)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (options.Format != "W" && Optional.IsDefined(Operator)) + { + writer.WritePropertyName("operator"u8); + writer.WriteStringValue(Operator); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ComponentExpressionEvaluationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentExpressionEvaluationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeComponentExpressionEvaluationDetails(document.RootElement, options); + } + + internal static ComponentExpressionEvaluationDetails DeserializeComponentExpressionEvaluationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string result = default; + string expression = default; + string expressionKind = default; + string path = default; + BinaryData expressionValue = default; + BinaryData targetValue = default; + string @operator = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("result"u8)) + { + result = property.Value.GetString(); + continue; + } + if (property.NameEquals("expression"u8)) + { + expression = property.Value.GetString(); + continue; + } + if (property.NameEquals("expressionKind"u8)) + { + expressionKind = property.Value.GetString(); + continue; + } + if (property.NameEquals("path"u8)) + { + path = property.Value.GetString(); + continue; + } + if (property.NameEquals("expressionValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expressionValue = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("targetValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetValue = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("operator"u8)) + { + @operator = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ComponentExpressionEvaluationDetails( + result, + expression, + expressionKind, + path, + expressionValue, + targetValue, + @operator, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ComponentExpressionEvaluationDetails)} does not support writing '{options.Format}' format."); + } + } + + ComponentExpressionEvaluationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeComponentExpressionEvaluationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ComponentExpressionEvaluationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentExpressionEvaluationDetails.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentExpressionEvaluationDetails.cs new file mode 100644 index 000000000000..386106902096 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentExpressionEvaluationDetails.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// Evaluation details of policy language expressions. + public partial class ComponentExpressionEvaluationDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ComponentExpressionEvaluationDetails() + { + } + + /// Initializes a new instance of . + /// Evaluation result. + /// Expression evaluated. + /// The kind of expression that was evaluated. + /// Property path if the expression is a field or an alias. + /// Value of the expression. + /// Target value to be compared with the expression value. + /// Operator to compare the expression value and the target value. + /// Keeps track of any properties unknown to the library. + internal ComponentExpressionEvaluationDetails(string result, string expression, string expressionKind, string path, BinaryData expressionValue, BinaryData targetValue, string @operator, IDictionary serializedAdditionalRawData) + { + Result = result; + Expression = expression; + ExpressionKind = expressionKind; + Path = path; + ExpressionValue = expressionValue; + TargetValue = targetValue; + Operator = @operator; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Evaluation result. + public string Result { get; } + /// Expression evaluated. + public string Expression { get; } + /// The kind of expression that was evaluated. + public string ExpressionKind { get; } + /// Property path if the expression is a field or an alias. + public string Path { get; } + /// + /// Value of the expression. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ExpressionValue { get; } + /// + /// Target value to be compared with the expression value. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData TargetValue { get; } + /// Operator to compare the expression value and the target value. + public string Operator { get; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyEvaluationDetails.Serialization.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyEvaluationDetails.Serialization.cs new file mode 100644 index 000000000000..4d4b54d96a4b --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyEvaluationDetails.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + public partial class ComponentPolicyEvaluationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentPolicyEvaluationDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(EvaluatedExpressions)) + { + writer.WritePropertyName("evaluatedExpressions"u8); + writer.WriteStartArray(); + foreach (var item in EvaluatedExpressions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ComponentPolicyEvaluationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentPolicyEvaluationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeComponentPolicyEvaluationDetails(document.RootElement, options); + } + + internal static ComponentPolicyEvaluationDetails DeserializeComponentPolicyEvaluationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList evaluatedExpressions = default; + string reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("evaluatedExpressions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ComponentExpressionEvaluationDetails.DeserializeComponentExpressionEvaluationDetails(item, options)); + } + evaluatedExpressions = array; + continue; + } + if (property.NameEquals("reason"u8)) + { + reason = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ComponentPolicyEvaluationDetails(evaluatedExpressions ?? new ChangeTrackingList(), reason, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ComponentPolicyEvaluationDetails)} does not support writing '{options.Format}' format."); + } + } + + ComponentPolicyEvaluationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeComponentPolicyEvaluationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ComponentPolicyEvaluationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyEvaluationDetails.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyEvaluationDetails.cs new file mode 100644 index 000000000000..aab7c2e5343e --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyEvaluationDetails.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// Policy evaluation details. + public partial class ComponentPolicyEvaluationDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ComponentPolicyEvaluationDetails() + { + EvaluatedExpressions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Details of the evaluated expressions. + /// Additional textual reason for the evaluation outcome. + /// Keeps track of any properties unknown to the library. + internal ComponentPolicyEvaluationDetails(IReadOnlyList evaluatedExpressions, string reason, IDictionary serializedAdditionalRawData) + { + EvaluatedExpressions = evaluatedExpressions; + Reason = reason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Details of the evaluated expressions. + public IReadOnlyList EvaluatedExpressions { get; } + /// Additional textual reason for the evaluation outcome. + public string Reason { get; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyState.Serialization.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyState.Serialization.cs new file mode 100644 index 000000000000..132a3217a6eb --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyState.Serialization.cs @@ -0,0 +1,519 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + public partial class ComponentPolicyState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentPolicyState)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ODataId)) + { + writer.WritePropertyName("@odata.id"u8); + writer.WriteStringValue(ODataId); + } + if (options.Format != "W" && Optional.IsDefined(ODataContext)) + { + writer.WritePropertyName("@odata.context"u8); + writer.WriteStringValue(ODataContext); + } + if (options.Format != "W" && Optional.IsDefined(Timestamp)) + { + writer.WritePropertyName("timestamp"u8); + writer.WriteStringValue(Timestamp.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ComponentId)) + { + writer.WritePropertyName("componentId"u8); + writer.WriteStringValue(ComponentId); + } + if (options.Format != "W" && Optional.IsDefined(ComponentType)) + { + writer.WritePropertyName("componentType"u8); + writer.WriteStringValue(ComponentType); + } + if (options.Format != "W" && Optional.IsDefined(ComponentName)) + { + writer.WritePropertyName("componentName"u8); + writer.WriteStringValue(ComponentName); + } + if (options.Format != "W" && Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + if (options.Format != "W" && Optional.IsDefined(PolicyAssignmentId)) + { + writer.WritePropertyName("policyAssignmentId"u8); + writer.WriteStringValue(PolicyAssignmentId); + } + if (options.Format != "W" && Optional.IsDefined(PolicyDefinitionId)) + { + writer.WritePropertyName("policyDefinitionId"u8); + writer.WriteStringValue(PolicyDefinitionId); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (options.Format != "W" && Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(ResourceLocation)) + { + writer.WritePropertyName("resourceLocation"u8); + writer.WriteStringValue(ResourceLocation); + } + if (options.Format != "W" && Optional.IsDefined(ResourceGroup)) + { + writer.WritePropertyName("resourceGroup"u8); + writer.WriteStringValue(ResourceGroup); + } + if (options.Format != "W" && Optional.IsDefined(PolicyAssignmentName)) + { + writer.WritePropertyName("policyAssignmentName"u8); + writer.WriteStringValue(PolicyAssignmentName); + } + if (options.Format != "W" && Optional.IsDefined(PolicyAssignmentOwner)) + { + writer.WritePropertyName("policyAssignmentOwner"u8); + writer.WriteStringValue(PolicyAssignmentOwner); + } + if (options.Format != "W" && Optional.IsDefined(PolicyAssignmentParameters)) + { + writer.WritePropertyName("policyAssignmentParameters"u8); + writer.WriteStringValue(PolicyAssignmentParameters); + } + if (options.Format != "W" && Optional.IsDefined(PolicyAssignmentScope)) + { + writer.WritePropertyName("policyAssignmentScope"u8); + writer.WriteStringValue(PolicyAssignmentScope); + } + if (options.Format != "W" && Optional.IsDefined(PolicyDefinitionName)) + { + writer.WritePropertyName("policyDefinitionName"u8); + writer.WriteStringValue(PolicyDefinitionName); + } + if (options.Format != "W" && Optional.IsDefined(PolicyDefinitionAction)) + { + writer.WritePropertyName("policyDefinitionAction"u8); + writer.WriteStringValue(PolicyDefinitionAction); + } + if (options.Format != "W" && Optional.IsDefined(PolicyDefinitionCategory)) + { + writer.WritePropertyName("policyDefinitionCategory"u8); + writer.WriteStringValue(PolicyDefinitionCategory); + } + if (options.Format != "W" && Optional.IsDefined(PolicySetDefinitionId)) + { + writer.WritePropertyName("policySetDefinitionId"u8); + writer.WriteStringValue(PolicySetDefinitionId); + } + if (options.Format != "W" && Optional.IsDefined(PolicySetDefinitionName)) + { + writer.WritePropertyName("policySetDefinitionName"u8); + writer.WriteStringValue(PolicySetDefinitionName); + } + if (options.Format != "W" && Optional.IsDefined(PolicySetDefinitionOwner)) + { + writer.WritePropertyName("policySetDefinitionOwner"u8); + writer.WriteStringValue(PolicySetDefinitionOwner); + } + if (options.Format != "W" && Optional.IsDefined(PolicySetDefinitionCategory)) + { + writer.WritePropertyName("policySetDefinitionCategory"u8); + writer.WriteStringValue(PolicySetDefinitionCategory); + } + if (options.Format != "W" && Optional.IsDefined(PolicySetDefinitionParameters)) + { + writer.WritePropertyName("policySetDefinitionParameters"u8); + writer.WriteStringValue(PolicySetDefinitionParameters); + } + if (options.Format != "W" && Optional.IsDefined(PolicyDefinitionReferenceId)) + { + writer.WritePropertyName("policyDefinitionReferenceId"u8); + writer.WriteStringValue(PolicyDefinitionReferenceId); + } + if (options.Format != "W" && Optional.IsDefined(ComplianceState)) + { + writer.WritePropertyName("complianceState"u8); + writer.WriteStringValue(ComplianceState); + } + if (Optional.IsDefined(PolicyEvaluationDetails)) + { + writer.WritePropertyName("policyEvaluationDetails"u8); + writer.WriteObjectValue(PolicyEvaluationDetails, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PolicyDefinitionGroupNames)) + { + writer.WritePropertyName("policyDefinitionGroupNames"u8); + writer.WriteStartArray(); + foreach (var item in PolicyDefinitionGroupNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(PolicyDefinitionVersion)) + { + writer.WritePropertyName("policyDefinitionVersion"u8); + writer.WriteStringValue(PolicyDefinitionVersion); + } + if (options.Format != "W" && Optional.IsDefined(PolicySetDefinitionVersion)) + { + writer.WritePropertyName("policySetDefinitionVersion"u8); + writer.WriteStringValue(PolicySetDefinitionVersion); + } + if (options.Format != "W" && Optional.IsDefined(PolicyAssignmentVersion)) + { + writer.WritePropertyName("policyAssignmentVersion"u8); + writer.WriteStringValue(PolicyAssignmentVersion); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + + ComponentPolicyState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentPolicyState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeComponentPolicyState(document.RootElement, options); + } + + internal static ComponentPolicyState DeserializeComponentPolicyState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string odataId = default; + string odataContext = default; + DateTimeOffset? timestamp = default; + string componentId = default; + string componentType = default; + string componentName = default; + string resourceId = default; + string policyAssignmentId = default; + string policyDefinitionId = default; + string subscriptionId = default; + string resourceType = default; + string resourceLocation = default; + string resourceGroup = default; + string policyAssignmentName = default; + string policyAssignmentOwner = default; + string policyAssignmentParameters = default; + string policyAssignmentScope = default; + string policyDefinitionName = default; + string policyDefinitionAction = default; + string policyDefinitionCategory = default; + string policySetDefinitionId = default; + string policySetDefinitionName = default; + string policySetDefinitionOwner = default; + string policySetDefinitionCategory = default; + string policySetDefinitionParameters = default; + string policyDefinitionReferenceId = default; + string complianceState = default; + ComponentPolicyEvaluationDetails policyEvaluationDetails = default; + IReadOnlyList policyDefinitionGroupNames = default; + string policyDefinitionVersion = default; + string policySetDefinitionVersion = default; + string policyAssignmentVersion = default; + IReadOnlyDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("@odata.id"u8)) + { + odataId = property.Value.GetString(); + continue; + } + if (property.NameEquals("@odata.context"u8)) + { + odataContext = property.Value.GetString(); + continue; + } + if (property.NameEquals("timestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("componentId"u8)) + { + componentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("componentType"u8)) + { + componentType = property.Value.GetString(); + continue; + } + if (property.NameEquals("componentName"u8)) + { + componentName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceId"u8)) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyAssignmentId"u8)) + { + policyAssignmentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyDefinitionId"u8)) + { + policyDefinitionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceLocation"u8)) + { + resourceLocation = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceGroup"u8)) + { + resourceGroup = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyAssignmentName"u8)) + { + policyAssignmentName = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyAssignmentOwner"u8)) + { + policyAssignmentOwner = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyAssignmentParameters"u8)) + { + policyAssignmentParameters = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyAssignmentScope"u8)) + { + policyAssignmentScope = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyDefinitionName"u8)) + { + policyDefinitionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyDefinitionAction"u8)) + { + policyDefinitionAction = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyDefinitionCategory"u8)) + { + policyDefinitionCategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("policySetDefinitionId"u8)) + { + policySetDefinitionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("policySetDefinitionName"u8)) + { + policySetDefinitionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("policySetDefinitionOwner"u8)) + { + policySetDefinitionOwner = property.Value.GetString(); + continue; + } + if (property.NameEquals("policySetDefinitionCategory"u8)) + { + policySetDefinitionCategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("policySetDefinitionParameters"u8)) + { + policySetDefinitionParameters = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyDefinitionReferenceId"u8)) + { + policyDefinitionReferenceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("complianceState"u8)) + { + complianceState = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyEvaluationDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + policyEvaluationDetails = ComponentPolicyEvaluationDetails.DeserializeComponentPolicyEvaluationDetails(property.Value, options); + continue; + } + if (property.NameEquals("policyDefinitionGroupNames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + policyDefinitionGroupNames = array; + continue; + } + if (property.NameEquals("policyDefinitionVersion"u8)) + { + policyDefinitionVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("policySetDefinitionVersion"u8)) + { + policySetDefinitionVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("policyAssignmentVersion"u8)) + { + policyAssignmentVersion = property.Value.GetString(); + continue; + } + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + additionalProperties = additionalPropertiesDictionary; + return new ComponentPolicyState( + odataId, + odataContext, + timestamp, + componentId, + componentType, + componentName, + resourceId, + policyAssignmentId, + policyDefinitionId, + subscriptionId, + resourceType, + resourceLocation, + resourceGroup, + policyAssignmentName, + policyAssignmentOwner, + policyAssignmentParameters, + policyAssignmentScope, + policyDefinitionName, + policyDefinitionAction, + policyDefinitionCategory, + policySetDefinitionId, + policySetDefinitionName, + policySetDefinitionOwner, + policySetDefinitionCategory, + policySetDefinitionParameters, + policyDefinitionReferenceId, + complianceState, + policyEvaluationDetails, + policyDefinitionGroupNames ?? new ChangeTrackingList(), + policyDefinitionVersion, + policySetDefinitionVersion, + policyAssignmentVersion, + additionalProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ComponentPolicyState)} does not support writing '{options.Format}' format."); + } + } + + ComponentPolicyState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeComponentPolicyState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ComponentPolicyState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyState.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyState.cs new file mode 100644 index 000000000000..a7350144069c --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyState.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// Component Policy State record. + public partial class ComponentPolicyState + { + /// Initializes a new instance of . + internal ComponentPolicyState() + { + PolicyDefinitionGroupNames = new ChangeTrackingList(); + AdditionalProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// OData entity ID; always set to null since component policy state records do not have an entity ID. + /// OData context string; used by OData clients to resolve type information based on metadata. + /// Timestamp for the component policy state record. + /// Component Id. + /// Component type. + /// Component name. + /// Resource ID. + /// Policy assignment ID. + /// Policy definition ID. + /// Subscription ID. + /// Resource type. + /// Resource location. + /// Resource group name. + /// Policy assignment name. + /// Policy assignment owner. + /// Policy assignment parameters. + /// Policy assignment scope. + /// Policy definition name. + /// Policy definition action, i.e. effect. + /// Policy definition category. + /// Policy set definition ID, if the policy assignment is for a policy set. + /// Policy set definition name, if the policy assignment is for a policy set. + /// Policy set definition owner, if the policy assignment is for a policy set. + /// Policy set definition category, if the policy assignment is for a policy set. + /// Policy set definition parameters, if the policy assignment is for a policy set. + /// Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. + /// Compliance state of the resource. + /// Policy evaluation details. This is only included in the response if the request contains $expand=PolicyEvaluationDetails. + /// Policy definition group names. + /// Evaluated policy definition version. + /// Evaluated policy set definition version. + /// Evaluated policy assignment version. + /// Additional Properties. + internal ComponentPolicyState(string odataId, string odataContext, DateTimeOffset? timestamp, string componentId, string componentType, string componentName, string resourceId, string policyAssignmentId, string policyDefinitionId, string subscriptionId, string resourceType, string resourceLocation, string resourceGroup, string policyAssignmentName, string policyAssignmentOwner, string policyAssignmentParameters, string policyAssignmentScope, string policyDefinitionName, string policyDefinitionAction, string policyDefinitionCategory, string policySetDefinitionId, string policySetDefinitionName, string policySetDefinitionOwner, string policySetDefinitionCategory, string policySetDefinitionParameters, string policyDefinitionReferenceId, string complianceState, ComponentPolicyEvaluationDetails policyEvaluationDetails, IReadOnlyList policyDefinitionGroupNames, string policyDefinitionVersion, string policySetDefinitionVersion, string policyAssignmentVersion, IReadOnlyDictionary additionalProperties) + { + ODataId = odataId; + ODataContext = odataContext; + Timestamp = timestamp; + ComponentId = componentId; + ComponentType = componentType; + ComponentName = componentName; + ResourceId = resourceId; + PolicyAssignmentId = policyAssignmentId; + PolicyDefinitionId = policyDefinitionId; + SubscriptionId = subscriptionId; + ResourceType = resourceType; + ResourceLocation = resourceLocation; + ResourceGroup = resourceGroup; + PolicyAssignmentName = policyAssignmentName; + PolicyAssignmentOwner = policyAssignmentOwner; + PolicyAssignmentParameters = policyAssignmentParameters; + PolicyAssignmentScope = policyAssignmentScope; + PolicyDefinitionName = policyDefinitionName; + PolicyDefinitionAction = policyDefinitionAction; + PolicyDefinitionCategory = policyDefinitionCategory; + PolicySetDefinitionId = policySetDefinitionId; + PolicySetDefinitionName = policySetDefinitionName; + PolicySetDefinitionOwner = policySetDefinitionOwner; + PolicySetDefinitionCategory = policySetDefinitionCategory; + PolicySetDefinitionParameters = policySetDefinitionParameters; + PolicyDefinitionReferenceId = policyDefinitionReferenceId; + ComplianceState = complianceState; + PolicyEvaluationDetails = policyEvaluationDetails; + PolicyDefinitionGroupNames = policyDefinitionGroupNames; + PolicyDefinitionVersion = policyDefinitionVersion; + PolicySetDefinitionVersion = policySetDefinitionVersion; + PolicyAssignmentVersion = policyAssignmentVersion; + AdditionalProperties = additionalProperties; + } + + /// OData entity ID; always set to null since component policy state records do not have an entity ID. + public string ODataId { get; } + /// OData context string; used by OData clients to resolve type information based on metadata. + public string ODataContext { get; } + /// Timestamp for the component policy state record. + public DateTimeOffset? Timestamp { get; } + /// Component Id. + public string ComponentId { get; } + /// Component type. + public string ComponentType { get; } + /// Component name. + public string ComponentName { get; } + /// Resource ID. + public string ResourceId { get; } + /// Policy assignment ID. + public string PolicyAssignmentId { get; } + /// Policy definition ID. + public string PolicyDefinitionId { get; } + /// Subscription ID. + public string SubscriptionId { get; } + /// Resource type. + public string ResourceType { get; } + /// Resource location. + public string ResourceLocation { get; } + /// Resource group name. + public string ResourceGroup { get; } + /// Policy assignment name. + public string PolicyAssignmentName { get; } + /// Policy assignment owner. + public string PolicyAssignmentOwner { get; } + /// Policy assignment parameters. + public string PolicyAssignmentParameters { get; } + /// Policy assignment scope. + public string PolicyAssignmentScope { get; } + /// Policy definition name. + public string PolicyDefinitionName { get; } + /// Policy definition action, i.e. effect. + public string PolicyDefinitionAction { get; } + /// Policy definition category. + public string PolicyDefinitionCategory { get; } + /// Policy set definition ID, if the policy assignment is for a policy set. + public string PolicySetDefinitionId { get; } + /// Policy set definition name, if the policy assignment is for a policy set. + public string PolicySetDefinitionName { get; } + /// Policy set definition owner, if the policy assignment is for a policy set. + public string PolicySetDefinitionOwner { get; } + /// Policy set definition category, if the policy assignment is for a policy set. + public string PolicySetDefinitionCategory { get; } + /// Policy set definition parameters, if the policy assignment is for a policy set. + public string PolicySetDefinitionParameters { get; } + /// Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. + public string PolicyDefinitionReferenceId { get; } + /// Compliance state of the resource. + public string ComplianceState { get; } + /// Policy evaluation details. This is only included in the response if the request contains $expand=PolicyEvaluationDetails. + public ComponentPolicyEvaluationDetails PolicyEvaluationDetails { get; } + /// Policy definition group names. + public IReadOnlyList PolicyDefinitionGroupNames { get; } + /// Evaluated policy definition version. + public string PolicyDefinitionVersion { get; } + /// Evaluated policy set definition version. + public string PolicySetDefinitionVersion { get; } + /// Evaluated policy assignment version. + public string PolicyAssignmentVersion { get; } + /// + /// Additional Properties + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary AdditionalProperties { get; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesQueryResults.Serialization.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesQueryResults.Serialization.cs new file mode 100644 index 000000000000..7dd91c05301c --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesQueryResults.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + internal partial class ComponentPolicyStatesQueryResults : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentPolicyStatesQueryResults)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ODataContext)) + { + writer.WritePropertyName("@odata.context"u8); + writer.WriteStringValue(ODataContext); + } + if (Optional.IsDefined(ODataCount)) + { + writer.WritePropertyName("@odata.count"u8); + writer.WriteNumberValue(ODataCount.Value); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ComponentPolicyStatesQueryResults IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComponentPolicyStatesQueryResults)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeComponentPolicyStatesQueryResults(document.RootElement, options); + } + + internal static ComponentPolicyStatesQueryResults DeserializeComponentPolicyStatesQueryResults(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string odataContext = default; + int? odataCount = default; + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("@odata.context"u8)) + { + odataContext = property.Value.GetString(); + continue; + } + if (property.NameEquals("@odata.count"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + odataCount = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ComponentPolicyState.DeserializeComponentPolicyState(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ComponentPolicyStatesQueryResults(odataContext, odataCount, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ComponentPolicyStatesQueryResults)} does not support writing '{options.Format}' format."); + } + } + + ComponentPolicyStatesQueryResults IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeComponentPolicyStatesQueryResults(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ComponentPolicyStatesQueryResults)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesQueryResults.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesQueryResults.cs new file mode 100644 index 000000000000..9f34209102e5 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesQueryResults.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// Query results. + internal partial class ComponentPolicyStatesQueryResults + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ComponentPolicyStatesQueryResults() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// 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. + /// Keeps track of any properties unknown to the library. + internal ComponentPolicyStatesQueryResults(string odataContext, int? odataCount, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + ODataContext = odataContext; + ODataCount = odataCount; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// OData context string; used by OData clients to resolve type information based on metadata. + public string ODataContext { get; } + /// OData entity count; represents the number of policy state records returned. + public int? ODataCount { get; } + /// Query results. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesResource.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesResource.cs new file mode 100644 index 000000000000..8135e7d41927 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ComponentPolicyStatesResource.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The ComponentPolicyStatesResource. + public readonly partial struct ComponentPolicyStatesResource : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ComponentPolicyStatesResource(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LatestValue = "latest"; + + /// latest. + public static ComponentPolicyStatesResource Latest { get; } = new ComponentPolicyStatesResource(LatestValue); + /// Determines if two values are the same. + public static bool operator ==(ComponentPolicyStatesResource left, ComponentPolicyStatesResource right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ComponentPolicyStatesResource left, ComponentPolicyStatesResource right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ComponentPolicyStatesResource(string value) => new ComponentPolicyStatesResource(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComponentPolicyStatesResource other && Equals(other); + /// + public bool Equals(ComponentPolicyStatesResource other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions.cs new file mode 100644 index 000000000000..140304297ebe --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions. + public partial class ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions + { + /// Initializes a new instance of . + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions(ComponentPolicyStatesResource componentPolicyStatesResource) + { + ComponentPolicyStatesResource = componentPolicyStatesResource; + } + + /// Initializes a new instance of for deserialization. + internal ResourceGroupResourceGetQueryResultsForResourceGroupComponentPolicyStatesOptions() + { + } + + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ComponentPolicyStatesResource ComponentPolicyStatesResource { get; } + /// Maximum number of records to return. + public int? Top { get; set; } + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + public string OrderBy { get; set; } + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + public string Select { get; set; } + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + public DateTimeOffset? From { get; set; } + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + public DateTimeOffset? To { get; set; } + /// OData filter expression. + public string Filter { get; set; } + /// OData apply expression for aggregations. + public string Apply { get; set; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions.cs new file mode 100644 index 000000000000..4defa1de47e0 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions. + public partial class ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions + { + /// Initializes a new instance of . + /// Policy assignment name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// is null. + public ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions(string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource) + { + Argument.AssertNotNull(policyAssignmentName, nameof(policyAssignmentName)); + + PolicyAssignmentName = policyAssignmentName; + ComponentPolicyStatesResource = componentPolicyStatesResource; + } + + /// Initializes a new instance of for deserialization. + internal ResourceGroupResourceGetQueryResultsForResourceGroupLevelPolicyAssignmentComponentPolicyStatesOptions() + { + } + + /// Policy assignment name. + public string PolicyAssignmentName { get; } + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ComponentPolicyStatesResource ComponentPolicyStatesResource { get; } + /// Maximum number of records to return. + public int? Top { get; set; } + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + public string OrderBy { get; set; } + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + public string Select { get; set; } + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + public DateTimeOffset? From { get; set; } + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + public DateTimeOffset? To { get; set; } + /// OData filter expression. + public string Filter { get; set; } + /// OData apply expression for aggregations. + public string Apply { get; set; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions.cs new file mode 100644 index 000000000000..34f9b30aea17 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions. + public partial class SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions + { + /// Initializes a new instance of . + /// Policy definition name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// is null. + public SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions(string policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource) + { + Argument.AssertNotNull(policyDefinitionName, nameof(policyDefinitionName)); + + PolicyDefinitionName = policyDefinitionName; + ComponentPolicyStatesResource = componentPolicyStatesResource; + } + + /// Initializes a new instance of for deserialization. + internal SubscriptionResourceGetQueryResultsForPolicyDefinitionComponentPolicyStatesOptions() + { + } + + /// Policy definition name. + public string PolicyDefinitionName { get; } + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ComponentPolicyStatesResource ComponentPolicyStatesResource { get; } + /// Maximum number of records to return. + public int? Top { get; set; } + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + public string OrderBy { get; set; } + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + public string Select { get; set; } + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + public DateTimeOffset? From { get; set; } + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + public DateTimeOffset? To { get; set; } + /// OData filter expression. + public string Filter { get; set; } + /// OData apply expression for aggregations. + public string Apply { get; set; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions.cs new file mode 100644 index 000000000000..b558324fef1b --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions. + public partial class SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions + { + /// Initializes a new instance of . + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions(ComponentPolicyStatesResource componentPolicyStatesResource) + { + ComponentPolicyStatesResource = componentPolicyStatesResource; + } + + /// Initializes a new instance of for deserialization. + internal SubscriptionResourceGetQueryResultsForSubscriptionComponentPolicyStatesOptions() + { + } + + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ComponentPolicyStatesResource ComponentPolicyStatesResource { get; } + /// Maximum number of records to return. + public int? Top { get; set; } + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + public string OrderBy { get; set; } + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + public string Select { get; set; } + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + public DateTimeOffset? From { get; set; } + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + public DateTimeOffset? To { get; set; } + /// OData filter expression. + public string Filter { get; set; } + /// OData apply expression for aggregations. + public string Apply { get; set; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions.cs new file mode 100644 index 000000000000..757eef7707bd --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/Models/SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.PolicyInsights.Models +{ + /// The SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions. + public partial class SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions + { + /// Initializes a new instance of . + /// Policy assignment name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// is null. + public SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions(string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource) + { + Argument.AssertNotNull(policyAssignmentName, nameof(policyAssignmentName)); + + PolicyAssignmentName = policyAssignmentName; + ComponentPolicyStatesResource = componentPolicyStatesResource; + } + + /// Initializes a new instance of for deserialization. + internal SubscriptionResourceGetQueryResultsForSubscriptionLevelPolicyAssignmentComponentPolicyStatesOptions() + { + } + + /// Policy assignment name. + public string PolicyAssignmentName { get; } + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + public ComponentPolicyStatesResource ComponentPolicyStatesResource { get; } + /// Maximum number of records to return. + public int? Top { get; set; } + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + public string OrderBy { get; set; } + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + public string Select { get; set; } + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + public DateTimeOffset? From { get; set; } + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + public DateTimeOffset? To { get; set; } + /// OData filter expression. + public string Filter { get; set; } + /// OData apply expression for aggregations. + public string Apply { get; set; } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/PolicyRemediationData.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/PolicyRemediationData.cs index 1e39afc50daa..5c80edea65e7 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/PolicyRemediationData.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/PolicyRemediationData.cs @@ -64,7 +64,7 @@ public PolicyRemediationData() /// The resource ID of the policy assignment that should be remediated. /// The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition. /// The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified. - /// The status of the remediation. + /// The status of the remediation. This refers to the entire remediation task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, Complete, or Succeeded. /// The time at which the remediation was created. /// The time at which the remediation was last updated. /// The filters that will be applied to determine which resources to remediate. @@ -99,7 +99,7 @@ internal PolicyRemediationData(ResourceIdentifier id, string name, ResourceType public string PolicyDefinitionReferenceId { get; set; } /// The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified. public ResourceDiscoveryMode? ResourceDiscoveryMode { get; set; } - /// The status of the remediation. + /// The status of the remediation. This refers to the entire remediation task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, Complete, or Succeeded. public string ProvisioningState { get; } /// The time at which the remediation was created. public DateTimeOffset? CreatedOn { get; } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/RestOperations/ComponentPolicyStatesRestOperations.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/RestOperations/ComponentPolicyStatesRestOperations.cs new file mode 100644 index 000000000000..41050845b521 --- /dev/null +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/Generated/RestOperations/ComponentPolicyStatesRestOperations.cs @@ -0,0 +1,1023 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.PolicyInsights.Models; + +namespace Azure.ResourceManager.PolicyInsights +{ + internal partial class ComponentPolicyStatesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ComponentPolicyStatesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public ComponentPolicyStatesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-04-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListQueryResultsForSubscriptionRequestUri(string subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + return uri; + } + + internal HttpMessage CreateListQueryResultsForSubscriptionRequest(string subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Queries component policy states under subscription scope. + /// Microsoft Azure subscription ID. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListQueryResultsForSubscriptionAsync(string subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListQueryResultsForSubscriptionRequest(subscriptionId, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queries component policy states under subscription scope. + /// Microsoft Azure subscription ID. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListQueryResultsForSubscription(string subscriptionId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListQueryResultsForSubscriptionRequest(subscriptionId, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListQueryResultsForResourceGroupRequestUri(string subscriptionId, string resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + return uri; + } + + internal HttpMessage CreateListQueryResultsForResourceGroupRequest(string subscriptionId, string resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Queries component policy states under resource group scope. + /// Microsoft Azure subscription ID. + /// Resource group name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListQueryResultsForResourceGroupAsync(string subscriptionId, string resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListQueryResultsForResourceGroupRequest(subscriptionId, resourceGroupName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queries component policy states under resource group scope. + /// Microsoft Azure subscription ID. + /// Resource group name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListQueryResultsForResourceGroup(string subscriptionId, string resourceGroupName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListQueryResultsForResourceGroupRequest(subscriptionId, resourceGroupName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListQueryResultsForResourceRequestUri(string resourceId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply, string expand) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceId, false); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + if (expand != null) + { + uri.AppendQuery("$expand", expand, true); + } + return uri; + } + + internal HttpMessage CreateListQueryResultsForResourceRequest(string resourceId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply, string expand) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceId, false); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + if (expand != null) + { + uri.AppendQuery("$expand", expand, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Queries component policy states for the resource. + /// Resource ID. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The $expand query parameter. + /// The cancellation token to use. + /// is null. + public async Task> ListQueryResultsForResourceAsync(string resourceId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, string expand = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + + using var message = CreateListQueryResultsForResourceRequest(resourceId, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply, expand); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queries component policy states for the resource. + /// Resource ID. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The $expand query parameter. + /// The cancellation token to use. + /// is null. + public Response ListQueryResultsForResource(string resourceId, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, string expand = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + + using var message = CreateListQueryResultsForResourceRequest(resourceId, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply, expand); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListQueryResultsForPolicyDefinitionRequestUri(string subscriptionId, string policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/", false); + uri.AppendPath("Microsoft.Authorization", true); + uri.AppendPath("/policyDefinitions/", false); + uri.AppendPath(policyDefinitionName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + return uri; + } + + internal HttpMessage CreateListQueryResultsForPolicyDefinitionRequest(string subscriptionId, string policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/", false); + uri.AppendPath("Microsoft.Authorization", true); + uri.AppendPath("/policyDefinitions/", false); + uri.AppendPath(policyDefinitionName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Queries component policy states for the subscription level policy definition. + /// Microsoft Azure subscription ID. + /// Policy definition name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListQueryResultsForPolicyDefinitionAsync(string subscriptionId, string policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(policyDefinitionName, nameof(policyDefinitionName)); + + using var message = CreateListQueryResultsForPolicyDefinitionRequest(subscriptionId, policyDefinitionName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queries component policy states for the subscription level policy definition. + /// Microsoft Azure subscription ID. + /// Policy definition name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListQueryResultsForPolicyDefinition(string subscriptionId, string policyDefinitionName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(policyDefinitionName, nameof(policyDefinitionName)); + + using var message = CreateListQueryResultsForPolicyDefinitionRequest(subscriptionId, policyDefinitionName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListQueryResultsForSubscriptionLevelPolicyAssignmentRequestUri(string subscriptionId, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/", false); + uri.AppendPath("Microsoft.Authorization", true); + uri.AppendPath("/policyAssignments/", false); + uri.AppendPath(policyAssignmentName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + return uri; + } + + internal HttpMessage CreateListQueryResultsForSubscriptionLevelPolicyAssignmentRequest(string subscriptionId, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/", false); + uri.AppendPath("Microsoft.Authorization", true); + uri.AppendPath("/policyAssignments/", false); + uri.AppendPath(policyAssignmentName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Queries component policy states for the subscription level policy assignment. + /// Microsoft Azure subscription ID. + /// Policy assignment name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListQueryResultsForSubscriptionLevelPolicyAssignmentAsync(string subscriptionId, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); + + using var message = CreateListQueryResultsForSubscriptionLevelPolicyAssignmentRequest(subscriptionId, policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queries component policy states for the subscription level policy assignment. + /// Microsoft Azure subscription ID. + /// Policy assignment name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListQueryResultsForSubscriptionLevelPolicyAssignment(string subscriptionId, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); + + using var message = CreateListQueryResultsForSubscriptionLevelPolicyAssignmentRequest(subscriptionId, policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListQueryResultsForResourceGroupLevelPolicyAssignmentRequestUri(string subscriptionId, string resourceGroupName, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/", false); + uri.AppendPath("Microsoft.Authorization", true); + uri.AppendPath("/policyAssignments/", false); + uri.AppendPath(policyAssignmentName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + return uri; + } + + internal HttpMessage CreateListQueryResultsForResourceGroupLevelPolicyAssignmentRequest(string subscriptionId, string resourceGroupName, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top, string orderBy, string select, DateTimeOffset? @from, DateTimeOffset? to, string filter, string apply) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/", false); + uri.AppendPath("Microsoft.Authorization", true); + uri.AppendPath("/policyAssignments/", false); + uri.AppendPath(policyAssignmentName, true); + uri.AppendPath("/providers/Microsoft.PolicyInsights/componentPolicyStates/", false); + uri.AppendPath(componentPolicyStatesResource.ToString(), true); + uri.AppendPath("/queryResults", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (orderBy != null) + { + uri.AppendQuery("$orderby", orderBy, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (@from != null) + { + uri.AppendQuery("$from", @from.Value, "O", true); + } + if (to != null) + { + uri.AppendQuery("$to", to.Value, "O", true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (apply != null) + { + uri.AppendQuery("$apply", apply, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Queries component policy states for the resource group level policy assignment. + /// Microsoft Azure subscription ID. + /// Resource group name. + /// Policy assignment name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListQueryResultsForResourceGroupLevelPolicyAssignmentAsync(string subscriptionId, string resourceGroupName, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); + + using var message = CreateListQueryResultsForResourceGroupLevelPolicyAssignmentRequest(subscriptionId, resourceGroupName, policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queries component policy states for the resource group level policy assignment. + /// Microsoft Azure subscription ID. + /// Resource group name. + /// Policy assignment name. + /// The virtual resource under ComponentPolicyStates resource type. In a given time range, 'latest' represents the latest component policy state(s). + /// Maximum number of records to return. + /// Ordering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". + /// Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". + /// ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). + /// ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. + /// OData filter expression. + /// OData apply expression for aggregations. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListQueryResultsForResourceGroupLevelPolicyAssignment(string subscriptionId, string resourceGroupName, string policyAssignmentName, ComponentPolicyStatesResource componentPolicyStatesResource, int? top = null, string orderBy = null, string select = null, DateTimeOffset? @from = null, DateTimeOffset? to = null, string filter = null, string apply = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); + + using var message = CreateListQueryResultsForResourceGroupLevelPolicyAssignmentRequest(subscriptionId, resourceGroupName, policyAssignmentName, componentPolicyStatesResource, top, orderBy, select, @from, to, filter, apply); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ComponentPolicyStatesQueryResults value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ComponentPolicyStatesQueryResults.DeserializeComponentPolicyStatesQueryResults(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/autorest.md b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/autorest.md index 6599f133d9e2..2c38742a1935 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/autorest.md +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/src/autorest.md @@ -8,7 +8,7 @@ azure-arm: true csharp: true library-name: PolicyInsights namespace: Azure.ResourceManager.PolicyInsights -require: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/policyinsights/resource-manager/readme.md tag: package-2022-09 output-folder: $(this-folder)/Generated clear-output-folder: true