Documentation ¶
Index ¶
- type Attestation
- type AttestationEvidence
- type AttestationListResult
- type AttestationProperties
- type AttestationsClient
- func (client *AttestationsClient) BeginCreateOrUpdateAtResource(ctx context.Context, resourceID string, attestationName string, ...) (*runtime.Poller[AttestationsClientCreateOrUpdateAtResourceResponse], error)
- func (client *AttestationsClient) BeginCreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, ...) (*runtime.Poller[AttestationsClientCreateOrUpdateAtResourceGroupResponse], ...)
- func (client *AttestationsClient) BeginCreateOrUpdateAtSubscription(ctx context.Context, attestationName string, parameters Attestation, ...) (*runtime.Poller[AttestationsClientCreateOrUpdateAtSubscriptionResponse], error)
- func (client *AttestationsClient) DeleteAtResource(ctx context.Context, resourceID string, attestationName string, ...) (AttestationsClientDeleteAtResourceResponse, error)
- func (client *AttestationsClient) DeleteAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, ...) (AttestationsClientDeleteAtResourceGroupResponse, error)
- func (client *AttestationsClient) DeleteAtSubscription(ctx context.Context, attestationName string, ...) (AttestationsClientDeleteAtSubscriptionResponse, error)
- func (client *AttestationsClient) GetAtResource(ctx context.Context, resourceID string, attestationName string, ...) (AttestationsClientGetAtResourceResponse, error)
- func (client *AttestationsClient) GetAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, ...) (AttestationsClientGetAtResourceGroupResponse, error)
- func (client *AttestationsClient) GetAtSubscription(ctx context.Context, attestationName string, ...) (AttestationsClientGetAtSubscriptionResponse, error)
- func (client *AttestationsClient) NewListForResourceGroupPager(resourceGroupName string, queryOptions *QueryOptions, ...) *runtime.Pager[AttestationsClientListForResourceGroupResponse]
- func (client *AttestationsClient) NewListForResourcePager(resourceID string, queryOptions *QueryOptions, ...) *runtime.Pager[AttestationsClientListForResourceResponse]
- func (client *AttestationsClient) NewListForSubscriptionPager(queryOptions *QueryOptions, ...) *runtime.Pager[AttestationsClientListForSubscriptionResponse]
- type AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions
- type AttestationsClientBeginCreateOrUpdateAtResourceOptions
- type AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions
- type AttestationsClientCreateOrUpdateAtResourceGroupResponse
- type AttestationsClientCreateOrUpdateAtResourceResponse
- type AttestationsClientCreateOrUpdateAtSubscriptionResponse
- type AttestationsClientDeleteAtResourceGroupOptions
- type AttestationsClientDeleteAtResourceGroupResponse
- type AttestationsClientDeleteAtResourceOptions
- type AttestationsClientDeleteAtResourceResponse
- type AttestationsClientDeleteAtSubscriptionOptions
- type AttestationsClientDeleteAtSubscriptionResponse
- type AttestationsClientGetAtResourceGroupOptions
- type AttestationsClientGetAtResourceGroupResponse
- type AttestationsClientGetAtResourceOptions
- type AttestationsClientGetAtResourceResponse
- type AttestationsClientGetAtSubscriptionOptions
- type AttestationsClientGetAtSubscriptionResponse
- type AttestationsClientListForResourceGroupOptions
- type AttestationsClientListForResourceGroupResponse
- type AttestationsClientListForResourceOptions
- type AttestationsClientListForResourceResponse
- type AttestationsClientListForSubscriptionOptions
- type AttestationsClientListForSubscriptionResponse
- type CheckManagementGroupRestrictionsRequest
- type CheckRestrictionsRequest
- type CheckRestrictionsResourceDetails
- type CheckRestrictionsResult
- type CheckRestrictionsResultContentEvaluationResult
- type ClientFactory
- func (c *ClientFactory) NewAttestationsClient() *AttestationsClient
- func (c *ClientFactory) NewOperationsClient() *OperationsClient
- func (c *ClientFactory) NewPolicyEventsClient() *PolicyEventsClient
- func (c *ClientFactory) NewPolicyMetadataClient() *PolicyMetadataClient
- func (c *ClientFactory) NewPolicyRestrictionsClient() *PolicyRestrictionsClient
- func (c *ClientFactory) NewPolicyStatesClient() *PolicyStatesClient
- func (c *ClientFactory) NewPolicyTrackedResourcesClient() *PolicyTrackedResourcesClient
- func (c *ClientFactory) NewRemediationsClient() *RemediationsClient
- type ComplianceDetail
- type ComplianceState
- type ComponentEventDetails
- type ComponentStateDetails
- type CreatedByType
- type ErrorDefinition
- type ErrorDefinitionAutoGenerated
- type ErrorDefinitionAutoGenerated2
- type ErrorResponse
- type ErrorResponseAutoGenerated
- type ErrorResponseAutoGenerated2
- type ExpressionEvaluationDetails
- type FieldRestriction
- type FieldRestrictionResult
- type FieldRestrictions
- type IfNotExistsEvaluationDetails
- type Operation
- type OperationDisplay
- type OperationsClient
- type OperationsClientListOptions
- type OperationsClientListResponse
- type OperationsListResults
- type PendingField
- type PolicyAssignmentSummary
- type PolicyDefinitionSummary
- type PolicyDetails
- type PolicyEvaluationDetails
- type PolicyEvaluationResult
- type PolicyEvent
- type PolicyEventsClient
- func (client *PolicyEventsClient) NewListQueryResultsForManagementGroupPager(policyEventsResource PolicyEventsResourceType, managementGroupName string, ...) *runtime.Pager[PolicyEventsClientListQueryResultsForManagementGroupResponse]
- func (client *PolicyEventsClient) NewListQueryResultsForPolicyDefinitionPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, ...) *runtime.Pager[PolicyEventsClientListQueryResultsForPolicyDefinitionResponse]
- func (client *PolicyEventsClient) NewListQueryResultsForPolicySetDefinitionPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, ...) ...
- func (client *PolicyEventsClient) NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, ...) ...
- func (client *PolicyEventsClient) NewListQueryResultsForResourceGroupPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, ...) *runtime.Pager[PolicyEventsClientListQueryResultsForResourceGroupResponse]
- func (client *PolicyEventsClient) NewListQueryResultsForResourcePager(policyEventsResource PolicyEventsResourceType, resourceID string, ...) *runtime.Pager[PolicyEventsClientListQueryResultsForResourceResponse]
- func (client *PolicyEventsClient) NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, ...) ...
- func (client *PolicyEventsClient) NewListQueryResultsForSubscriptionPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, ...) *runtime.Pager[PolicyEventsClientListQueryResultsForSubscriptionResponse]
- type PolicyEventsClientListQueryResultsForManagementGroupOptions
- type PolicyEventsClientListQueryResultsForManagementGroupResponse
- type PolicyEventsClientListQueryResultsForPolicyDefinitionOptions
- type PolicyEventsClientListQueryResultsForPolicyDefinitionResponse
- type PolicyEventsClientListQueryResultsForPolicySetDefinitionOptions
- type PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse
- type PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions
- type PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse
- type PolicyEventsClientListQueryResultsForResourceGroupOptions
- type PolicyEventsClientListQueryResultsForResourceGroupResponse
- type PolicyEventsClientListQueryResultsForResourceOptions
- type PolicyEventsClientListQueryResultsForResourceResponse
- type PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions
- type PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse
- type PolicyEventsClientListQueryResultsForSubscriptionOptions
- type PolicyEventsClientListQueryResultsForSubscriptionResponse
- type PolicyEventsQueryResults
- type PolicyEventsResourceType
- type PolicyGroupSummary
- type PolicyMetadata
- type PolicyMetadataClient
- func (client *PolicyMetadataClient) GetResource(ctx context.Context, resourceName string, ...) (PolicyMetadataClientGetResourceResponse, error)
- func (client *PolicyMetadataClient) NewListPager(queryOptions *QueryOptions, options *PolicyMetadataClientListOptions) *runtime.Pager[PolicyMetadataClientListResponse]
- type PolicyMetadataClientGetResourceOptions
- type PolicyMetadataClientGetResourceResponse
- type PolicyMetadataClientListOptions
- type PolicyMetadataClientListResponse
- type PolicyMetadataCollection
- type PolicyMetadataProperties
- type PolicyMetadataSlimProperties
- type PolicyReference
- type PolicyRestrictionsClient
- func (client *PolicyRestrictionsClient) CheckAtManagementGroupScope(ctx context.Context, managementGroupID string, ...) (PolicyRestrictionsClientCheckAtManagementGroupScopeResponse, error)
- func (client *PolicyRestrictionsClient) CheckAtResourceGroupScope(ctx context.Context, resourceGroupName string, ...) (PolicyRestrictionsClientCheckAtResourceGroupScopeResponse, error)
- func (client *PolicyRestrictionsClient) CheckAtSubscriptionScope(ctx context.Context, parameters CheckRestrictionsRequest, ...) (PolicyRestrictionsClientCheckAtSubscriptionScopeResponse, error)
- type PolicyRestrictionsClientCheckAtManagementGroupScopeOptions
- type PolicyRestrictionsClientCheckAtManagementGroupScopeResponse
- type PolicyRestrictionsClientCheckAtResourceGroupScopeOptions
- type PolicyRestrictionsClientCheckAtResourceGroupScopeResponse
- type PolicyRestrictionsClientCheckAtSubscriptionScopeOptions
- type PolicyRestrictionsClientCheckAtSubscriptionScopeResponse
- type PolicyState
- type PolicyStatesClient
- func (client *PolicyStatesClient) BeginTriggerResourceGroupEvaluation(ctx context.Context, subscriptionID string, resourceGroupName string, ...) (*runtime.Poller[PolicyStatesClientTriggerResourceGroupEvaluationResponse], ...)
- func (client *PolicyStatesClient) BeginTriggerSubscriptionEvaluation(ctx context.Context, subscriptionID string, ...) (*runtime.Poller[PolicyStatesClientTriggerSubscriptionEvaluationResponse], ...)
- func (client *PolicyStatesClient) NewListQueryResultsForManagementGroupPager(policyStatesResource PolicyStatesResource, managementGroupName string, ...) *runtime.Pager[PolicyStatesClientListQueryResultsForManagementGroupResponse]
- func (client *PolicyStatesClient) NewListQueryResultsForPolicyDefinitionPager(policyStatesResource PolicyStatesResource, subscriptionID string, ...) *runtime.Pager[PolicyStatesClientListQueryResultsForPolicyDefinitionResponse]
- func (client *PolicyStatesClient) NewListQueryResultsForPolicySetDefinitionPager(policyStatesResource PolicyStatesResource, subscriptionID string, ...) ...
- func (client *PolicyStatesClient) NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(policyStatesResource PolicyStatesResource, subscriptionID string, ...) ...
- func (client *PolicyStatesClient) NewListQueryResultsForResourceGroupPager(policyStatesResource PolicyStatesResource, subscriptionID string, ...) *runtime.Pager[PolicyStatesClientListQueryResultsForResourceGroupResponse]
- func (client *PolicyStatesClient) NewListQueryResultsForResourcePager(policyStatesResource PolicyStatesResource, resourceID string, ...) *runtime.Pager[PolicyStatesClientListQueryResultsForResourceResponse]
- func (client *PolicyStatesClient) NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(policyStatesResource PolicyStatesResource, subscriptionID string, ...) ...
- func (client *PolicyStatesClient) NewListQueryResultsForSubscriptionPager(policyStatesResource PolicyStatesResource, subscriptionID string, ...) *runtime.Pager[PolicyStatesClientListQueryResultsForSubscriptionResponse]
- func (client *PolicyStatesClient) SummarizeForManagementGroup(ctx context.Context, ...) (PolicyStatesClientSummarizeForManagementGroupResponse, error)
- func (client *PolicyStatesClient) SummarizeForPolicyDefinition(ctx context.Context, ...) (PolicyStatesClientSummarizeForPolicyDefinitionResponse, error)
- func (client *PolicyStatesClient) SummarizeForPolicySetDefinition(ctx context.Context, ...) (PolicyStatesClientSummarizeForPolicySetDefinitionResponse, error)
- func (client *PolicyStatesClient) SummarizeForResource(ctx context.Context, ...) (PolicyStatesClientSummarizeForResourceResponse, error)
- func (client *PolicyStatesClient) SummarizeForResourceGroup(ctx context.Context, ...) (PolicyStatesClientSummarizeForResourceGroupResponse, error)
- func (client *PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignment(ctx context.Context, ...) (PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResponse, ...)
- func (client *PolicyStatesClient) SummarizeForSubscription(ctx context.Context, ...) (PolicyStatesClientSummarizeForSubscriptionResponse, error)
- func (client *PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignment(ctx context.Context, ...) (PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResponse, error)
- type PolicyStatesClientBeginTriggerResourceGroupEvaluationOptions
- type PolicyStatesClientBeginTriggerSubscriptionEvaluationOptions
- type PolicyStatesClientListQueryResultsForManagementGroupOptions
- type PolicyStatesClientListQueryResultsForManagementGroupResponse
- type PolicyStatesClientListQueryResultsForPolicyDefinitionOptions
- type PolicyStatesClientListQueryResultsForPolicyDefinitionResponse
- type PolicyStatesClientListQueryResultsForPolicySetDefinitionOptions
- type PolicyStatesClientListQueryResultsForPolicySetDefinitionResponse
- type PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions
- type PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse
- type PolicyStatesClientListQueryResultsForResourceGroupOptions
- type PolicyStatesClientListQueryResultsForResourceGroupResponse
- type PolicyStatesClientListQueryResultsForResourceOptions
- type PolicyStatesClientListQueryResultsForResourceResponse
- type PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions
- type PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse
- type PolicyStatesClientListQueryResultsForSubscriptionOptions
- type PolicyStatesClientListQueryResultsForSubscriptionResponse
- type PolicyStatesClientSummarizeForManagementGroupOptions
- type PolicyStatesClientSummarizeForManagementGroupResponse
- type PolicyStatesClientSummarizeForPolicyDefinitionOptions
- type PolicyStatesClientSummarizeForPolicyDefinitionResponse
- type PolicyStatesClientSummarizeForPolicySetDefinitionOptions
- type PolicyStatesClientSummarizeForPolicySetDefinitionResponse
- type PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentOptions
- type PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResponse
- type PolicyStatesClientSummarizeForResourceGroupOptions
- type PolicyStatesClientSummarizeForResourceGroupResponse
- type PolicyStatesClientSummarizeForResourceOptions
- type PolicyStatesClientSummarizeForResourceResponse
- type PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentOptions
- type PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResponse
- type PolicyStatesClientSummarizeForSubscriptionOptions
- type PolicyStatesClientSummarizeForSubscriptionResponse
- type PolicyStatesClientTriggerResourceGroupEvaluationResponse
- type PolicyStatesClientTriggerSubscriptionEvaluationResponse
- type PolicyStatesQueryResults
- type PolicyStatesResource
- type PolicyStatesSummaryResourceType
- type PolicyTrackedResource
- type PolicyTrackedResourcesClient
- func (client *PolicyTrackedResourcesClient) NewListQueryResultsForManagementGroupPager(managementGroupName string, ...) ...
- func (client *PolicyTrackedResourcesClient) NewListQueryResultsForResourceGroupPager(resourceGroupName string, ...) ...
- func (client *PolicyTrackedResourcesClient) NewListQueryResultsForResourcePager(resourceID string, ...) ...
- func (client *PolicyTrackedResourcesClient) NewListQueryResultsForSubscriptionPager(policyTrackedResourcesResource PolicyTrackedResourcesResourceType, ...) ...
- type PolicyTrackedResourcesClientListQueryResultsForManagementGroupOptions
- type PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse
- type PolicyTrackedResourcesClientListQueryResultsForResourceGroupOptions
- type PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse
- type PolicyTrackedResourcesClientListQueryResultsForResourceOptions
- type PolicyTrackedResourcesClientListQueryResultsForResourceResponse
- type PolicyTrackedResourcesClientListQueryResultsForSubscriptionOptions
- type PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse
- type PolicyTrackedResourcesQueryResults
- type PolicyTrackedResourcesResourceType
- type QueryFailure
- type QueryFailureError
- type QueryOptions
- type Remediation
- type RemediationDeployment
- type RemediationDeploymentSummary
- type RemediationDeploymentsListResult
- type RemediationFilters
- type RemediationListResult
- type RemediationProperties
- type RemediationPropertiesFailureThreshold
- type RemediationsClient
- func (client *RemediationsClient) CancelAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, ...) (RemediationsClientCancelAtManagementGroupResponse, error)
- func (client *RemediationsClient) CancelAtResource(ctx context.Context, resourceID string, remediationName string, ...) (RemediationsClientCancelAtResourceResponse, error)
- func (client *RemediationsClient) CancelAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, ...) (RemediationsClientCancelAtResourceGroupResponse, error)
- func (client *RemediationsClient) CancelAtSubscription(ctx context.Context, remediationName string, ...) (RemediationsClientCancelAtSubscriptionResponse, error)
- func (client *RemediationsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, ...) (RemediationsClientCreateOrUpdateAtManagementGroupResponse, error)
- func (client *RemediationsClient) CreateOrUpdateAtResource(ctx context.Context, resourceID string, remediationName string, ...) (RemediationsClientCreateOrUpdateAtResourceResponse, error)
- func (client *RemediationsClient) CreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, ...) (RemediationsClientCreateOrUpdateAtResourceGroupResponse, error)
- func (client *RemediationsClient) CreateOrUpdateAtSubscription(ctx context.Context, remediationName string, parameters Remediation, ...) (RemediationsClientCreateOrUpdateAtSubscriptionResponse, error)
- func (client *RemediationsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, ...) (RemediationsClientDeleteAtManagementGroupResponse, error)
- func (client *RemediationsClient) DeleteAtResource(ctx context.Context, resourceID string, remediationName string, ...) (RemediationsClientDeleteAtResourceResponse, error)
- func (client *RemediationsClient) DeleteAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, ...) (RemediationsClientDeleteAtResourceGroupResponse, error)
- func (client *RemediationsClient) DeleteAtSubscription(ctx context.Context, remediationName string, ...) (RemediationsClientDeleteAtSubscriptionResponse, error)
- func (client *RemediationsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, ...) (RemediationsClientGetAtManagementGroupResponse, error)
- func (client *RemediationsClient) GetAtResource(ctx context.Context, resourceID string, remediationName string, ...) (RemediationsClientGetAtResourceResponse, error)
- func (client *RemediationsClient) GetAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, ...) (RemediationsClientGetAtResourceGroupResponse, error)
- func (client *RemediationsClient) GetAtSubscription(ctx context.Context, remediationName string, ...) (RemediationsClientGetAtSubscriptionResponse, error)
- func (client *RemediationsClient) NewListDeploymentsAtManagementGroupPager(managementGroupID string, remediationName string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListDeploymentsAtManagementGroupResponse]
- func (client *RemediationsClient) NewListDeploymentsAtResourceGroupPager(resourceGroupName string, remediationName string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListDeploymentsAtResourceGroupResponse]
- func (client *RemediationsClient) NewListDeploymentsAtResourcePager(resourceID string, remediationName string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListDeploymentsAtResourceResponse]
- func (client *RemediationsClient) NewListDeploymentsAtSubscriptionPager(remediationName string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListDeploymentsAtSubscriptionResponse]
- func (client *RemediationsClient) NewListForManagementGroupPager(managementGroupID string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListForManagementGroupResponse]
- func (client *RemediationsClient) NewListForResourceGroupPager(resourceGroupName string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListForResourceGroupResponse]
- func (client *RemediationsClient) NewListForResourcePager(resourceID string, queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListForResourceResponse]
- func (client *RemediationsClient) NewListForSubscriptionPager(queryOptions *QueryOptions, ...) *runtime.Pager[RemediationsClientListForSubscriptionResponse]
- type RemediationsClientCancelAtManagementGroupOptions
- type RemediationsClientCancelAtManagementGroupResponse
- type RemediationsClientCancelAtResourceGroupOptions
- type RemediationsClientCancelAtResourceGroupResponse
- type RemediationsClientCancelAtResourceOptions
- type RemediationsClientCancelAtResourceResponse
- type RemediationsClientCancelAtSubscriptionOptions
- type RemediationsClientCancelAtSubscriptionResponse
- type RemediationsClientCreateOrUpdateAtManagementGroupOptions
- type RemediationsClientCreateOrUpdateAtManagementGroupResponse
- type RemediationsClientCreateOrUpdateAtResourceGroupOptions
- type RemediationsClientCreateOrUpdateAtResourceGroupResponse
- type RemediationsClientCreateOrUpdateAtResourceOptions
- type RemediationsClientCreateOrUpdateAtResourceResponse
- type RemediationsClientCreateOrUpdateAtSubscriptionOptions
- type RemediationsClientCreateOrUpdateAtSubscriptionResponse
- type RemediationsClientDeleteAtManagementGroupOptions
- type RemediationsClientDeleteAtManagementGroupResponse
- type RemediationsClientDeleteAtResourceGroupOptions
- type RemediationsClientDeleteAtResourceGroupResponse
- type RemediationsClientDeleteAtResourceOptions
- type RemediationsClientDeleteAtResourceResponse
- type RemediationsClientDeleteAtSubscriptionOptions
- type RemediationsClientDeleteAtSubscriptionResponse
- type RemediationsClientGetAtManagementGroupOptions
- type RemediationsClientGetAtManagementGroupResponse
- type RemediationsClientGetAtResourceGroupOptions
- type RemediationsClientGetAtResourceGroupResponse
- type RemediationsClientGetAtResourceOptions
- type RemediationsClientGetAtResourceResponse
- type RemediationsClientGetAtSubscriptionOptions
- type RemediationsClientGetAtSubscriptionResponse
- type RemediationsClientListDeploymentsAtManagementGroupOptions
- type RemediationsClientListDeploymentsAtManagementGroupResponse
- type RemediationsClientListDeploymentsAtResourceGroupOptions
- type RemediationsClientListDeploymentsAtResourceGroupResponse
- type RemediationsClientListDeploymentsAtResourceOptions
- type RemediationsClientListDeploymentsAtResourceResponse
- type RemediationsClientListDeploymentsAtSubscriptionOptions
- type RemediationsClientListDeploymentsAtSubscriptionResponse
- type RemediationsClientListForManagementGroupOptions
- type RemediationsClientListForManagementGroupResponse
- type RemediationsClientListForResourceGroupOptions
- type RemediationsClientListForResourceGroupResponse
- type RemediationsClientListForResourceOptions
- type RemediationsClientListForResourceResponse
- type RemediationsClientListForSubscriptionOptions
- type RemediationsClientListForSubscriptionResponse
- type Resource
- type ResourceDiscoveryMode
- type SlimPolicyMetadata
- type SummarizeResults
- type Summary
- type SummaryResults
- type SystemData
- type TrackedResourceModificationDetails
- type TypedErrorInfo
Examples ¶
- AttestationsClient.BeginCreateOrUpdateAtResource
- AttestationsClient.BeginCreateOrUpdateAtResourceGroup
- AttestationsClient.BeginCreateOrUpdateAtSubscription (CreateAttestationAtSubscriptionScope)
- AttestationsClient.BeginCreateOrUpdateAtSubscription (CreateAttestationAtSubscriptionScopeWithAllProperties)
- AttestationsClient.DeleteAtResource
- AttestationsClient.DeleteAtResourceGroup
- AttestationsClient.DeleteAtSubscription
- AttestationsClient.GetAtResource
- AttestationsClient.GetAtResourceGroup
- AttestationsClient.GetAtSubscription
- AttestationsClient.NewListForResourceGroupPager (ListAttestationsAtResourceGroupScope)
- AttestationsClient.NewListForResourceGroupPager (ListAttestationsAtResourceGroupScopeWithQueryParameters)
- AttestationsClient.NewListForResourcePager (ListAttestationsAtIndividualResourceScope)
- AttestationsClient.NewListForResourcePager (ListAttestationsAtIndividualResourceScopeWithQueryParameters)
- AttestationsClient.NewListForSubscriptionPager (ListAttestationsAtSubscriptionScope)
- AttestationsClient.NewListForSubscriptionPager (ListAttestationsAtSubscriptionScopeWithQueryParameters)
- OperationsClient.List
- PolicyEventsClient.NewListQueryResultsForManagementGroupPager (QueryAtManagementGroupScope)
- PolicyEventsClient.NewListQueryResultsForManagementGroupPager (QueryAtManagementGroupScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForPolicyDefinitionPager (QueryAtSubscriptionLevelPolicyDefinitionScope)
- PolicyEventsClient.NewListQueryResultsForPolicyDefinitionPager (QueryAtSubscriptionLevelPolicyDefinitionScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForPolicySetDefinitionPager (QueryAtSubscriptionLevelPolicySetDefinitionScope)
- PolicyEventsClient.NewListQueryResultsForPolicySetDefinitionPager (QueryAtSubscriptionLevelPolicySetDefinitionScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager (QueryAtResourceGroupLevelPolicyAssignmentScope)
- PolicyEventsClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager (QueryAtResourceGroupLevelPolicyAssignmentScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForResourceGroupPager (QueryAtResourceGroupScope)
- PolicyEventsClient.NewListQueryResultsForResourceGroupPager (QueryAtResourceGroupScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryAtNestedResourceScope)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryAtResourceScope)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryAtResourceScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryAtSubscriptionLevelNestedResourceScope)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryAtSubscriptionLevelResourceScope)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryComponentsPolicyEventsCountGroupedByUserAndActionTypeForResourceScopeFilteredByGivenAssignment)
- PolicyEventsClient.NewListQueryResultsForResourcePager (QueryComponentsPolicyEventsForResourceScopeFilteredByGivenAssignment)
- PolicyEventsClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager (QueryAtSubscriptionLevelPolicyAssignmentScope)
- PolicyEventsClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager (QueryAtSubscriptionLevelPolicyAssignmentScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (FilterAndAggregateOnly)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (FilterAndGroupWithAggregate)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (FilterAndGroupWithoutAggregate)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (FilterAndMultipleGroups)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (QueryAtSubscriptionScope)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (QueryAtSubscriptionScopeWithNextLink)
- PolicyEventsClient.NewListQueryResultsForSubscriptionPager (TimeRangeSortSelectAndLimit)
- PolicyMetadataClient.GetResource
- PolicyMetadataClient.NewListPager (GetCollectionOfPolicyMetadataResources)
- PolicyMetadataClient.NewListPager (GetCollectionOfPolicyMetadataResourcesUsingTopQueryParameter)
- PolicyRestrictionsClient.CheckAtManagementGroupScope
- PolicyRestrictionsClient.CheckAtResourceGroupScope
- PolicyRestrictionsClient.CheckAtSubscriptionScope
- PolicyStatesClient.BeginTriggerResourceGroupEvaluation
- PolicyStatesClient.BeginTriggerSubscriptionEvaluation
- PolicyStatesClient.NewListQueryResultsForManagementGroupPager (QueryLatestAtManagementGroupScope)
- PolicyStatesClient.NewListQueryResultsForManagementGroupPager (QueryLatestAtManagementGroupScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForPolicyDefinitionPager (QueryLatestAtSubscriptionLevelPolicyDefinitionScope)
- PolicyStatesClient.NewListQueryResultsForPolicyDefinitionPager (QueryLatestAtSubscriptionLevelPolicyDefinitionScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForPolicySetDefinitionPager (QueryLatestAtSubscriptionLevelPolicySetDefinitionScope)
- PolicyStatesClient.NewListQueryResultsForPolicySetDefinitionPager (QueryLatestAtSubscriptionLevelPolicySetDefinitionScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager (QueryLatestAtResourceGroupLevelPolicyAssignmentScope)
- PolicyStatesClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager (QueryLatestAtResourceGroupLevelPolicyAssignmentScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForResourceGroupPager (QueryLatestAtResourceGroupScope)
- PolicyStatesClient.NewListQueryResultsForResourceGroupPager (QueryLatestAtResourceGroupScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryAllPolicyStatesAtNestedResourceScope)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryAllPolicyStatesAtResourceScope)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryAllPolicyStatesAtResourceScopeAndExpandPolicyEvaluationDetails)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryAllPolicyStatesAtResourceScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryAllPolicyStatesAtSubscriptionLevelNestedResourceScope)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryAllPolicyStatesAtSubscriptionLevelResourceScope)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryComponentPolicyComplianceStateAtResourceScopeFilteredByGivenAssignment)
- PolicyStatesClient.NewListQueryResultsForResourcePager (QueryComponentPolicyComplianceStateCountGroupedByStateTypeAtResourceScopeFilteredByGivenAssignment)
- PolicyStatesClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager (QueryLatestAtSubscriptionLevelPolicyAssignmentScope)
- PolicyStatesClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager (QueryLatestAtSubscriptionLevelPolicyAssignmentScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (FilterAndAggregateOnly)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (FilterAndGroupWithAggregate)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (FilterAndGroupWithoutAggregate)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (FilterAndMultipleGroups)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (QueryLatestAtSubscriptionScope)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (QueryLatestAtSubscriptionScopeWithNextLink)
- PolicyStatesClient.NewListQueryResultsForSubscriptionPager (TimeRangeSortSelectAndLimit)
- PolicyStatesClient.SummarizeForManagementGroup
- PolicyStatesClient.SummarizeForPolicyDefinition
- PolicyStatesClient.SummarizeForPolicySetDefinition
- PolicyStatesClient.SummarizeForResource
- PolicyStatesClient.SummarizeForResourceGroup
- PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment
- PolicyStatesClient.SummarizeForSubscription (SummarizeAtSubscriptionScope)
- PolicyStatesClient.SummarizeForSubscription (SummarizeAtSubscriptionScopeForAPolicyDefinitionGroup)
- PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment
- PolicyTrackedResourcesClient.NewListQueryResultsForManagementGroupPager (QueryAtManagementGroupScope)
- PolicyTrackedResourcesClient.NewListQueryResultsForManagementGroupPager (QueryAtManagementGroupScopeUsingQueryParameters)
- PolicyTrackedResourcesClient.NewListQueryResultsForResourceGroupPager (QueryAtResourceGroupScope)
- PolicyTrackedResourcesClient.NewListQueryResultsForResourceGroupPager (QueryAtResourceGroupScopeUsingQueryParameters)
- PolicyTrackedResourcesClient.NewListQueryResultsForResourcePager (QueryAtResourceScope)
- PolicyTrackedResourcesClient.NewListQueryResultsForResourcePager (QueryAtResourceScopeUsingQueryParameters)
- PolicyTrackedResourcesClient.NewListQueryResultsForSubscriptionPager (QueryAtSubscriptionScope)
- PolicyTrackedResourcesClient.NewListQueryResultsForSubscriptionPager (QueryAtSubscriptionScopeUsingQueryParameters)
- RemediationsClient.CancelAtManagementGroup
- RemediationsClient.CancelAtResource
- RemediationsClient.CancelAtResourceGroup
- RemediationsClient.CancelAtSubscription
- RemediationsClient.CreateOrUpdateAtManagementGroup
- RemediationsClient.CreateOrUpdateAtResource
- RemediationsClient.CreateOrUpdateAtResourceGroup
- RemediationsClient.CreateOrUpdateAtSubscription (CreateRemediationAtSubscriptionScope)
- RemediationsClient.CreateOrUpdateAtSubscription (CreateRemediationAtSubscriptionScopeWithAllProperties)
- RemediationsClient.DeleteAtManagementGroup
- RemediationsClient.DeleteAtResource
- RemediationsClient.DeleteAtResourceGroup
- RemediationsClient.DeleteAtSubscription
- RemediationsClient.GetAtManagementGroup
- RemediationsClient.GetAtResource
- RemediationsClient.GetAtResourceGroup
- RemediationsClient.GetAtSubscription
- RemediationsClient.NewListDeploymentsAtManagementGroupPager
- RemediationsClient.NewListDeploymentsAtResourceGroupPager
- RemediationsClient.NewListDeploymentsAtResourcePager
- RemediationsClient.NewListDeploymentsAtSubscriptionPager
- RemediationsClient.NewListForManagementGroupPager (ListRemediationsAtManagementGroupScope)
- RemediationsClient.NewListForManagementGroupPager (ListRemediationsAtManagementGroupScopeWithQueryParameters)
- RemediationsClient.NewListForResourceGroupPager (ListRemediationsAtResourceGroupScope)
- RemediationsClient.NewListForResourceGroupPager (ListRemediationsAtResourceGroupScopeWithQueryParameters)
- RemediationsClient.NewListForResourcePager (ListRemediationsAtIndividualResourceScope)
- RemediationsClient.NewListForResourcePager (ListRemediationsAtIndividualResourceScopeWithQueryParameters)
- RemediationsClient.NewListForSubscriptionPager (ListRemediationsAtSubscriptionScope)
- RemediationsClient.NewListForSubscriptionPager (ListRemediationsAtSubscriptionScopeWithQueryParameters)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attestation ¶
type Attestation struct { // REQUIRED; Properties for the attestation. Properties *AttestationProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string // READ-ONLY; The name of the resource Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string }
Attestation - An attestation resource.
func (Attestation) MarshalJSON ¶ added in v0.6.0
func (a Attestation) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type Attestation.
func (*Attestation) UnmarshalJSON ¶ added in v0.6.0
func (a *Attestation) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type Attestation.
type AttestationEvidence ¶
type AttestationEvidence struct { // The description for this piece of evidence. Description *string // The URI location of the evidence. SourceURI *string }
AttestationEvidence - A piece of evidence supporting the compliance state set in the attestation.
func (AttestationEvidence) MarshalJSON ¶ added in v0.6.0
func (a AttestationEvidence) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type AttestationEvidence.
func (*AttestationEvidence) UnmarshalJSON ¶ added in v0.6.0
func (a *AttestationEvidence) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type AttestationEvidence.
type AttestationListResult ¶
type AttestationListResult struct { // READ-ONLY; The URL to get the next set of results. NextLink *string // READ-ONLY; Array of attestation definitions. Value []*Attestation }
AttestationListResult - List of attestations.
func (AttestationListResult) MarshalJSON ¶
func (a AttestationListResult) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type AttestationListResult.
func (*AttestationListResult) UnmarshalJSON ¶ added in v0.6.0
func (a *AttestationListResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type AttestationListResult.
type AttestationProperties ¶
type AttestationProperties struct { // REQUIRED; The resource ID of the policy assignment that the attestation is setting the state for. PolicyAssignmentID *string // The time the evidence was assessed AssessmentDate *time.Time // Comments describing why this attestation was created. Comments *string // The compliance state that should be set on the resource. ComplianceState *ComplianceState // The evidence supporting the compliance state set in this attestation. Evidence []*AttestationEvidence // The time the compliance state should expire. ExpiresOn *time.Time // Additional metadata for this attestation Metadata any // The person responsible for setting the state of the resource. This value is typically an Azure Active Directory object // ID. Owner *string // The policy definition reference ID from a policy set definition that the attestation is setting the state for. If the policy // assignment assigns a policy set definition the attestation can choose a // definition within the set definition with this property or omit this and set the state for the entire set definition. PolicyDefinitionReferenceID *string // READ-ONLY; The time the compliance state was last changed in this attestation. LastComplianceStateChangeAt *time.Time // READ-ONLY; The status of the attestation. ProvisioningState *string }
AttestationProperties - The properties of an attestation resource.
func (AttestationProperties) MarshalJSON ¶
func (a AttestationProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type AttestationProperties.
func (*AttestationProperties) UnmarshalJSON ¶
func (a *AttestationProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type AttestationProperties.
type AttestationsClient ¶
type AttestationsClient struct {
// contains filtered or unexported fields
}
AttestationsClient contains the methods for the Attestations group. Don't use this type directly, use NewAttestationsClient() instead.
func NewAttestationsClient ¶
func NewAttestationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AttestationsClient, error)
NewAttestationsClient creates a new instance of AttestationsClient with the specified values.
- subscriptionID - Microsoft Azure subscription ID.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*AttestationsClient) BeginCreateOrUpdateAtResource ¶
func (client *AttestationsClient) BeginCreateOrUpdateAtResource(ctx context.Context, resourceID string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceOptions) (*runtime.Poller[AttestationsClientCreateOrUpdateAtResourceResponse], error)
BeginCreateOrUpdateAtResource - Creates or updates an attestation at resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- resourceID - Resource ID.
- attestationName - The name of the attestation.
- parameters - The attestation parameters.
- options - AttestationsClientBeginCreateOrUpdateAtResourceOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateResourceScope.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewAttestationsClient().BeginCreateOrUpdateAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", armpolicyinsights.Attestation{ Properties: &armpolicyinsights.AttestationProperties{ AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t }()), Comments: to.Ptr("This subscription has passed a security audit."), ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), Evidence: []*armpolicyinsights.AttestationEvidence{ { Description: to.Ptr("The results of the security audit."), SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), }}, ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t }()), Metadata: map[string]any{ "departmentId": "NYC-MARKETING-1", }, Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } res, err := poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*AttestationsClient) BeginCreateOrUpdateAtResourceGroup ¶
func (client *AttestationsClient) BeginCreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions) (*runtime.Poller[AttestationsClientCreateOrUpdateAtResourceGroupResponse], error)
BeginCreateOrUpdateAtResourceGroup - Creates or updates an attestation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- resourceGroupName - The name of the resource group. The name is case insensitive.
- attestationName - The name of the attestation.
- parameters - The attestation parameters.
- options - AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateResourceGroupScope.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewAttestationsClient().BeginCreateOrUpdateAtResourceGroup(ctx, "myRg", "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", armpolicyinsights.Attestation{ Properties: &armpolicyinsights.AttestationProperties{ AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t }()), Comments: to.Ptr("This subscription has passed a security audit."), ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), Evidence: []*armpolicyinsights.AttestationEvidence{ { Description: to.Ptr("The results of the security audit."), SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), }}, ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t }()), Metadata: map[string]any{ "departmentId": "NYC-MARKETING-1", }, Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } res, err := poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*AttestationsClient) BeginCreateOrUpdateAtSubscription ¶
func (client *AttestationsClient) BeginCreateOrUpdateAtSubscription(ctx context.Context, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions) (*runtime.Poller[AttestationsClientCreateOrUpdateAtSubscriptionResponse], error)
BeginCreateOrUpdateAtSubscription - Creates or updates an attestation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- attestationName - The name of the attestation.
- parameters - The attestation parameters.
- options - AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtSubscription method.
Example (CreateAttestationAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewAttestationsClient().BeginCreateOrUpdateAtSubscription(ctx, "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", armpolicyinsights.Attestation{ Properties: &armpolicyinsights.AttestationProperties{ ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } res, err := poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
Example (CreateAttestationAtSubscriptionScopeWithAllProperties) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateSubscriptionScope_AllProperties.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewAttestationsClient().BeginCreateOrUpdateAtSubscription(ctx, "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", armpolicyinsights.Attestation{ Properties: &armpolicyinsights.AttestationProperties{ AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t }()), Comments: to.Ptr("This subscription has passed a security audit."), ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), Evidence: []*armpolicyinsights.AttestationEvidence{ { Description: to.Ptr("The results of the security audit."), SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), }}, ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t }()), Metadata: map[string]any{ "departmentId": "NYC-MARKETING-1", }, Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } res, err := poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*AttestationsClient) DeleteAtResource ¶
func (client *AttestationsClient) DeleteAtResource(ctx context.Context, resourceID string, attestationName string, options *AttestationsClientDeleteAtResourceOptions) (AttestationsClientDeleteAtResourceResponse, error)
DeleteAtResource - Deletes an existing attestation at individual resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- resourceID - Resource ID.
- attestationName - The name of the attestation.
- options - AttestationsClientDeleteAtResourceOptions contains the optional parameters for the AttestationsClient.DeleteAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } _, err = clientFactory.NewAttestationsClient().DeleteAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } }
Output:
func (*AttestationsClient) DeleteAtResourceGroup ¶
func (client *AttestationsClient) DeleteAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, options *AttestationsClientDeleteAtResourceGroupOptions) (AttestationsClientDeleteAtResourceGroupResponse, error)
DeleteAtResourceGroup - Deletes an existing attestation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- resourceGroupName - The name of the resource group. The name is case insensitive.
- attestationName - The name of the attestation.
- options - AttestationsClientDeleteAtResourceGroupOptions contains the optional parameters for the AttestationsClient.DeleteAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } _, err = clientFactory.NewAttestationsClient().DeleteAtResourceGroup(ctx, "myRg", "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } }
Output:
func (*AttestationsClient) DeleteAtSubscription ¶
func (client *AttestationsClient) DeleteAtSubscription(ctx context.Context, attestationName string, options *AttestationsClientDeleteAtSubscriptionOptions) (AttestationsClientDeleteAtSubscriptionResponse, error)
DeleteAtSubscription - Deletes an existing attestation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- attestationName - The name of the attestation.
- options - AttestationsClientDeleteAtSubscriptionOptions contains the optional parameters for the AttestationsClient.DeleteAtSubscription method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } _, err = clientFactory.NewAttestationsClient().DeleteAtSubscription(ctx, "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } }
Output:
func (*AttestationsClient) GetAtResource ¶
func (client *AttestationsClient) GetAtResource(ctx context.Context, resourceID string, attestationName string, options *AttestationsClientGetAtResourceOptions) (AttestationsClientGetAtResourceResponse, error)
GetAtResource - Gets an existing attestation at resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- resourceID - Resource ID.
- attestationName - The name of the attestation.
- options - AttestationsClientGetAtResourceOptions contains the optional parameters for the AttestationsClient.GetAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewAttestationsClient().GetAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*AttestationsClient) GetAtResourceGroup ¶
func (client *AttestationsClient) GetAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, options *AttestationsClientGetAtResourceGroupOptions) (AttestationsClientGetAtResourceGroupResponse, error)
GetAtResourceGroup - Gets an existing attestation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- resourceGroupName - The name of the resource group. The name is case insensitive.
- attestationName - The name of the attestation.
- options - AttestationsClientGetAtResourceGroupOptions contains the optional parameters for the AttestationsClient.GetAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewAttestationsClient().GetAtResourceGroup(ctx, "myRg", "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*AttestationsClient) GetAtSubscription ¶
func (client *AttestationsClient) GetAtSubscription(ctx context.Context, attestationName string, options *AttestationsClientGetAtSubscriptionOptions) (AttestationsClientGetAtSubscriptionResponse, error)
GetAtSubscription - Gets an existing attestation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-09-01
- attestationName - The name of the attestation.
- options - AttestationsClientGetAtSubscriptionOptions contains the optional parameters for the AttestationsClient.GetAtSubscription method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewAttestationsClient().GetAtSubscription(ctx, "790996e6-9871-4b1f-9cd9-ec42cd6ced1e", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Attestation = armpolicyinsights.Attestation{ // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*AttestationsClient) NewListForResourceGroupPager ¶ added in v0.4.0
func (client *AttestationsClient) NewListForResourceGroupPager(resourceGroupName string, queryOptions *QueryOptions, options *AttestationsClientListForResourceGroupOptions) *runtime.Pager[AttestationsClientListForResourceGroupResponse]
NewListForResourceGroupPager - Gets all attestations for the resource group.
Generated from API version 2022-09-01
- resourceGroupName - The name of the resource group. The name is case insensitive.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - AttestationsClientListForResourceGroupOptions contains the optional parameters for the AttestationsClient.NewListForResourceGroupPager method.
Example (ListAttestationsAtResourceGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewAttestationsClient().NewListForResourceGroupPager("myRg", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.AttestationListResult = armpolicyinsights.AttestationListResult{ // Value: []*armpolicyinsights.Attestation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("689bfc0c-a012-49fc-af40-3ebea35ff3ed"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.policyinsights/attestations/689bfc0c-a012-49fc-af40-3ebea35ff3ed"), // Properties: &armpolicyinsights.AttestationProperties{ // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/090a47f8-13e9-441e-ad90-dc666cc5d487"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListAttestationsAtResourceGroupScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceGroupScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewAttestationsClient().NewListForResourceGroupPager("myRg", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq '0b158b46-ff42-4799-8e39-08a5c23b4551'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.AttestationListResult = armpolicyinsights.AttestationListResult{ // Value: []*armpolicyinsights.Attestation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
func (*AttestationsClient) NewListForResourcePager ¶ added in v0.4.0
func (client *AttestationsClient) NewListForResourcePager(resourceID string, queryOptions *QueryOptions, options *AttestationsClientListForResourceOptions) *runtime.Pager[AttestationsClientListForResourceResponse]
NewListForResourcePager - Gets all attestations for a resource.
Generated from API version 2022-09-01
- resourceID - Resource ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - AttestationsClientListForResourceOptions contains the optional parameters for the AttestationsClient.NewListForResourcePager method.
Example (ListAttestationsAtIndividualResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewAttestationsClient().NewListForResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.AttestationListResult = armpolicyinsights.AttestationListResult{ // Value: []*armpolicyinsights.Attestation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("689bfc0c-a012-49fc-af40-3ebea35ff3ed"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/689bfc0c-a012-49fc-af40-3ebea35ff3ed"), // Properties: &armpolicyinsights.AttestationProperties{ // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/090a47f8-13e9-441e-ad90-dc666cc5d487"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListAttestationsAtIndividualResourceScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewAttestationsClient().NewListForResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq '0b158b46-ff42-4799-8e39-08a5c23b4551'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.AttestationListResult = armpolicyinsights.AttestationListResult{ // Value: []*armpolicyinsights.Attestation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
func (*AttestationsClient) NewListForSubscriptionPager ¶ added in v0.4.0
func (client *AttestationsClient) NewListForSubscriptionPager(queryOptions *QueryOptions, options *AttestationsClientListForSubscriptionOptions) *runtime.Pager[AttestationsClientListForSubscriptionResponse]
NewListForSubscriptionPager - Gets all attestations for the subscription.
Generated from API version 2022-09-01
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - AttestationsClientListForSubscriptionOptions contains the optional parameters for the AttestationsClient.NewListForSubscriptionPager method.
Example (ListAttestationsAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewAttestationsClient().NewListForSubscriptionPager(&armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.AttestationListResult = armpolicyinsights.AttestationListResult{ // Value: []*armpolicyinsights.Attestation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("689bfc0c-a012-49fc-af40-3ebea35ff3ed"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.policyinsights/attestations/689bfc0c-a012-49fc-af40-3ebea35ff3ed"), // Properties: &armpolicyinsights.AttestationProperties{ // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/090a47f8-13e9-441e-ad90-dc666cc5d487"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListAttestationsAtSubscriptionScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListSubscriptionScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewAttestationsClient().NewListForSubscriptionPager(&armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq '0b158b46-ff42-4799-8e39-08a5c23b4551'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.AttestationListResult = armpolicyinsights.AttestationListResult{ // Value: []*armpolicyinsights.Attestation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/attestations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.AttestationProperties{ // AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()), // Comments: to.Ptr("This subscription has passed a security audit."), // ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant), // Evidence: []*armpolicyinsights.AttestationEvidence{ // { // Description: to.Ptr("The results of the security audit."), // SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), // }}, // ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()), // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // Metadata: map[string]any{ // "departmentId": "NYC-MARKETING-1", // }, // Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"), // ProvisioningState: to.Ptr("Succeeded"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
type AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions ¶
type AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions struct { // Resumes the LRO from the provided token. ResumeToken string }
AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtResourceGroup method.
type AttestationsClientBeginCreateOrUpdateAtResourceOptions ¶
type AttestationsClientBeginCreateOrUpdateAtResourceOptions struct { // Resumes the LRO from the provided token. ResumeToken string }
AttestationsClientBeginCreateOrUpdateAtResourceOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtResource method.
type AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions ¶
type AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions struct { // Resumes the LRO from the provided token. ResumeToken string }
AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtSubscription method.
type AttestationsClientCreateOrUpdateAtResourceGroupResponse ¶
type AttestationsClientCreateOrUpdateAtResourceGroupResponse struct { // An attestation resource. Attestation }
AttestationsClientCreateOrUpdateAtResourceGroupResponse contains the response from method AttestationsClient.BeginCreateOrUpdateAtResourceGroup.
type AttestationsClientCreateOrUpdateAtResourceResponse ¶
type AttestationsClientCreateOrUpdateAtResourceResponse struct { // An attestation resource. Attestation }
AttestationsClientCreateOrUpdateAtResourceResponse contains the response from method AttestationsClient.BeginCreateOrUpdateAtResource.
type AttestationsClientCreateOrUpdateAtSubscriptionResponse ¶
type AttestationsClientCreateOrUpdateAtSubscriptionResponse struct { // An attestation resource. Attestation }
AttestationsClientCreateOrUpdateAtSubscriptionResponse contains the response from method AttestationsClient.BeginCreateOrUpdateAtSubscription.
type AttestationsClientDeleteAtResourceGroupOptions ¶
type AttestationsClientDeleteAtResourceGroupOptions struct { }
AttestationsClientDeleteAtResourceGroupOptions contains the optional parameters for the AttestationsClient.DeleteAtResourceGroup method.
type AttestationsClientDeleteAtResourceGroupResponse ¶
type AttestationsClientDeleteAtResourceGroupResponse struct { }
AttestationsClientDeleteAtResourceGroupResponse contains the response from method AttestationsClient.DeleteAtResourceGroup.
type AttestationsClientDeleteAtResourceOptions ¶
type AttestationsClientDeleteAtResourceOptions struct { }
AttestationsClientDeleteAtResourceOptions contains the optional parameters for the AttestationsClient.DeleteAtResource method.
type AttestationsClientDeleteAtResourceResponse ¶
type AttestationsClientDeleteAtResourceResponse struct { }
AttestationsClientDeleteAtResourceResponse contains the response from method AttestationsClient.DeleteAtResource.
type AttestationsClientDeleteAtSubscriptionOptions ¶
type AttestationsClientDeleteAtSubscriptionOptions struct { }
AttestationsClientDeleteAtSubscriptionOptions contains the optional parameters for the AttestationsClient.DeleteAtSubscription method.
type AttestationsClientDeleteAtSubscriptionResponse ¶
type AttestationsClientDeleteAtSubscriptionResponse struct { }
AttestationsClientDeleteAtSubscriptionResponse contains the response from method AttestationsClient.DeleteAtSubscription.
type AttestationsClientGetAtResourceGroupOptions ¶
type AttestationsClientGetAtResourceGroupOptions struct { }
AttestationsClientGetAtResourceGroupOptions contains the optional parameters for the AttestationsClient.GetAtResourceGroup method.
type AttestationsClientGetAtResourceGroupResponse ¶
type AttestationsClientGetAtResourceGroupResponse struct { // An attestation resource. Attestation }
AttestationsClientGetAtResourceGroupResponse contains the response from method AttestationsClient.GetAtResourceGroup.
type AttestationsClientGetAtResourceOptions ¶
type AttestationsClientGetAtResourceOptions struct { }
AttestationsClientGetAtResourceOptions contains the optional parameters for the AttestationsClient.GetAtResource method.
type AttestationsClientGetAtResourceResponse ¶
type AttestationsClientGetAtResourceResponse struct { // An attestation resource. Attestation }
AttestationsClientGetAtResourceResponse contains the response from method AttestationsClient.GetAtResource.
type AttestationsClientGetAtSubscriptionOptions ¶
type AttestationsClientGetAtSubscriptionOptions struct { }
AttestationsClientGetAtSubscriptionOptions contains the optional parameters for the AttestationsClient.GetAtSubscription method.
type AttestationsClientGetAtSubscriptionResponse ¶
type AttestationsClientGetAtSubscriptionResponse struct { // An attestation resource. Attestation }
AttestationsClientGetAtSubscriptionResponse contains the response from method AttestationsClient.GetAtSubscription.
type AttestationsClientListForResourceGroupOptions ¶
type AttestationsClientListForResourceGroupOptions struct { }
AttestationsClientListForResourceGroupOptions contains the optional parameters for the AttestationsClient.NewListForResourceGroupPager method.
type AttestationsClientListForResourceGroupResponse ¶
type AttestationsClientListForResourceGroupResponse struct { // List of attestations. AttestationListResult }
AttestationsClientListForResourceGroupResponse contains the response from method AttestationsClient.NewListForResourceGroupPager.
type AttestationsClientListForResourceOptions ¶
type AttestationsClientListForResourceOptions struct { }
AttestationsClientListForResourceOptions contains the optional parameters for the AttestationsClient.NewListForResourcePager method.
type AttestationsClientListForResourceResponse ¶
type AttestationsClientListForResourceResponse struct { // List of attestations. AttestationListResult }
AttestationsClientListForResourceResponse contains the response from method AttestationsClient.NewListForResourcePager.
type AttestationsClientListForSubscriptionOptions ¶
type AttestationsClientListForSubscriptionOptions struct { }
AttestationsClientListForSubscriptionOptions contains the optional parameters for the AttestationsClient.NewListForSubscriptionPager method.
type AttestationsClientListForSubscriptionResponse ¶
type AttestationsClientListForSubscriptionResponse struct { // List of attestations. AttestationListResult }
AttestationsClientListForSubscriptionResponse contains the response from method AttestationsClient.NewListForSubscriptionPager.
type CheckManagementGroupRestrictionsRequest ¶ added in v0.3.0
type CheckManagementGroupRestrictionsRequest struct { // The list of fields and values that should be evaluated for potential restrictions. PendingFields []*PendingField // The information about the resource that will be evaluated. ResourceDetails *CheckRestrictionsResourceDetails }
CheckManagementGroupRestrictionsRequest - The check policy restrictions parameters describing the resource that is being evaluated.
func (CheckManagementGroupRestrictionsRequest) MarshalJSON ¶ added in v0.3.0
func (c CheckManagementGroupRestrictionsRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type CheckManagementGroupRestrictionsRequest.
func (*CheckManagementGroupRestrictionsRequest) UnmarshalJSON ¶ added in v0.6.0
func (c *CheckManagementGroupRestrictionsRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type CheckManagementGroupRestrictionsRequest.
type CheckRestrictionsRequest ¶
type CheckRestrictionsRequest struct { // REQUIRED; The information about the resource that will be evaluated. ResourceDetails *CheckRestrictionsResourceDetails // The list of fields and values that should be evaluated for potential restrictions. PendingFields []*PendingField }
CheckRestrictionsRequest - The check policy restrictions parameters describing the resource that is being evaluated.
func (CheckRestrictionsRequest) MarshalJSON ¶
func (c CheckRestrictionsRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type CheckRestrictionsRequest.
func (*CheckRestrictionsRequest) UnmarshalJSON ¶ added in v0.6.0
func (c *CheckRestrictionsRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type CheckRestrictionsRequest.
type CheckRestrictionsResourceDetails ¶
type CheckRestrictionsResourceDetails struct { // REQUIRED; The resource content. This should include whatever properties are already known and can be a partial set of all // resource properties. ResourceContent any // The api-version of the resource content. APIVersion *string // The scope where the resource is being created. For example, if the resource is a child resource this would be the parent // resource's resource ID. Scope *string }
CheckRestrictionsResourceDetails - The information about the resource that will be evaluated.
func (CheckRestrictionsResourceDetails) MarshalJSON ¶ added in v0.6.0
func (c CheckRestrictionsResourceDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type CheckRestrictionsResourceDetails.
func (*CheckRestrictionsResourceDetails) UnmarshalJSON ¶ added in v0.6.0
func (c *CheckRestrictionsResourceDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type CheckRestrictionsResourceDetails.
type CheckRestrictionsResult ¶
type CheckRestrictionsResult struct { // READ-ONLY; Evaluation results for the provided partial resource content. ContentEvaluationResult *CheckRestrictionsResultContentEvaluationResult // READ-ONLY; The restrictions that will be placed on various fields in the resource by policy. FieldRestrictions []*FieldRestrictions }
CheckRestrictionsResult - The result of a check policy restrictions evaluation on a resource.
func (CheckRestrictionsResult) MarshalJSON ¶
func (c CheckRestrictionsResult) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type CheckRestrictionsResult.
func (*CheckRestrictionsResult) UnmarshalJSON ¶ added in v0.6.0
func (c *CheckRestrictionsResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type CheckRestrictionsResult.
type CheckRestrictionsResultContentEvaluationResult ¶
type CheckRestrictionsResultContentEvaluationResult struct { // Policy evaluation results against the given resource content. This will indicate if the partial content that was provided // will be denied as-is. PolicyEvaluations []*PolicyEvaluationResult }
CheckRestrictionsResultContentEvaluationResult - Evaluation results for the provided partial resource content.
func (CheckRestrictionsResultContentEvaluationResult) MarshalJSON ¶
func (c CheckRestrictionsResultContentEvaluationResult) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type CheckRestrictionsResultContentEvaluationResult.
func (*CheckRestrictionsResultContentEvaluationResult) UnmarshalJSON ¶ added in v0.6.0
func (c *CheckRestrictionsResultContentEvaluationResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type CheckRestrictionsResultContentEvaluationResult.
type ClientFactory ¶ added in v0.7.0
type ClientFactory struct {
// contains filtered or unexported fields
}
ClientFactory is a client factory used to create any client in this module. Don't use this type directly, use NewClientFactory instead.
func NewClientFactory ¶ added in v0.7.0
func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error)
NewClientFactory creates a new instance of ClientFactory with the specified values. The parameter values will be propagated to any client created from this factory.
- subscriptionID - Microsoft Azure subscription ID.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*ClientFactory) NewAttestationsClient ¶ added in v0.7.0
func (c *ClientFactory) NewAttestationsClient() *AttestationsClient
NewAttestationsClient creates a new instance of AttestationsClient.
func (*ClientFactory) NewOperationsClient ¶ added in v0.7.0
func (c *ClientFactory) NewOperationsClient() *OperationsClient
NewOperationsClient creates a new instance of OperationsClient.
func (*ClientFactory) NewPolicyEventsClient ¶ added in v0.7.0
func (c *ClientFactory) NewPolicyEventsClient() *PolicyEventsClient
NewPolicyEventsClient creates a new instance of PolicyEventsClient.
func (*ClientFactory) NewPolicyMetadataClient ¶ added in v0.7.0
func (c *ClientFactory) NewPolicyMetadataClient() *PolicyMetadataClient
NewPolicyMetadataClient creates a new instance of PolicyMetadataClient.
func (*ClientFactory) NewPolicyRestrictionsClient ¶ added in v0.7.0
func (c *ClientFactory) NewPolicyRestrictionsClient() *PolicyRestrictionsClient
NewPolicyRestrictionsClient creates a new instance of PolicyRestrictionsClient.
func (*ClientFactory) NewPolicyStatesClient ¶ added in v0.7.0
func (c *ClientFactory) NewPolicyStatesClient() *PolicyStatesClient
NewPolicyStatesClient creates a new instance of PolicyStatesClient.
func (*ClientFactory) NewPolicyTrackedResourcesClient ¶ added in v0.7.0
func (c *ClientFactory) NewPolicyTrackedResourcesClient() *PolicyTrackedResourcesClient
NewPolicyTrackedResourcesClient creates a new instance of PolicyTrackedResourcesClient.
func (*ClientFactory) NewRemediationsClient ¶ added in v0.7.0
func (c *ClientFactory) NewRemediationsClient() *RemediationsClient
NewRemediationsClient creates a new instance of RemediationsClient.
type ComplianceDetail ¶
type ComplianceDetail struct { // The compliance state. ComplianceState *string // Summarized count value for this compliance state. Count *int32 }
ComplianceDetail - The compliance state rollup.
func (ComplianceDetail) MarshalJSON ¶ added in v0.6.0
func (c ComplianceDetail) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ComplianceDetail.
func (*ComplianceDetail) UnmarshalJSON ¶ added in v0.6.0
func (c *ComplianceDetail) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ComplianceDetail.
type ComplianceState ¶
type ComplianceState string
ComplianceState - The compliance state that should be set on the resource.
const ( // ComplianceStateCompliant - The resource is in compliance with the policy. ComplianceStateCompliant ComplianceState = "Compliant" // ComplianceStateNonCompliant - The resource is not in compliance with the policy. ComplianceStateNonCompliant ComplianceState = "NonCompliant" // ComplianceStateUnknown - The compliance state of the resource is not known. ComplianceStateUnknown ComplianceState = "Unknown" )
func PossibleComplianceStateValues ¶
func PossibleComplianceStateValues() []ComplianceState
PossibleComplianceStateValues returns the possible values for the ComplianceState const type.
type ComponentEventDetails ¶
type ComponentEventDetails struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. AdditionalProperties map[string]any // Component Id. ID *string // Component name. Name *string // Policy definition action, i.e. effect. PolicyDefinitionAction *string // Principal object ID for the user who initiated the resource component operation that triggered the policy event. PrincipalOid *string // Tenant ID for the policy event record. TenantID *string // Timestamp for component policy event record. Timestamp *time.Time // Component type. Type *string }
ComponentEventDetails - Component event details.
func (ComponentEventDetails) MarshalJSON ¶
func (c ComponentEventDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ComponentEventDetails.
func (*ComponentEventDetails) UnmarshalJSON ¶
func (c *ComponentEventDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ComponentEventDetails.
type ComponentStateDetails ¶
type ComponentStateDetails struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. AdditionalProperties map[string]any // Component compliance state. ComplianceState *string // Component Id. ID *string // Component name. Name *string // Component compliance evaluation timestamp. Timestamp *time.Time // Component type. Type *string }
ComponentStateDetails - Component state details.
func (ComponentStateDetails) MarshalJSON ¶
func (c ComponentStateDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ComponentStateDetails.
func (*ComponentStateDetails) UnmarshalJSON ¶
func (c *ComponentStateDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ComponentStateDetails.
type CreatedByType ¶
type CreatedByType string
CreatedByType - The type of identity that created the resource.
const ( CreatedByTypeApplication CreatedByType = "Application" CreatedByTypeKey CreatedByType = "Key" CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" CreatedByTypeUser CreatedByType = "User" )
func PossibleCreatedByTypeValues ¶
func PossibleCreatedByTypeValues() []CreatedByType
PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type.
type ErrorDefinition ¶
type ErrorDefinition struct { // READ-ONLY; Additional scenario specific error details. AdditionalInfo []*TypedErrorInfo // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. Code *string // READ-ONLY; Internal error details. Details []*ErrorDefinition // READ-ONLY; Description of the error. Message *string // READ-ONLY; The target of the error. Target *string }
ErrorDefinition - Error definition.
func (ErrorDefinition) MarshalJSON ¶
func (e ErrorDefinition) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ErrorDefinition.
func (*ErrorDefinition) UnmarshalJSON ¶ added in v0.6.0
func (e *ErrorDefinition) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDefinition.
type ErrorDefinitionAutoGenerated ¶
type ErrorDefinitionAutoGenerated struct { // READ-ONLY; Additional scenario specific error details. AdditionalInfo []*TypedErrorInfo // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. Code *string // READ-ONLY; Internal error details. Details []*ErrorDefinitionAutoGenerated // READ-ONLY; Description of the error. Message *string // READ-ONLY; The target of the error. Target *string }
ErrorDefinitionAutoGenerated - Error definition.
func (ErrorDefinitionAutoGenerated) MarshalJSON ¶
func (e ErrorDefinitionAutoGenerated) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ErrorDefinitionAutoGenerated.
func (*ErrorDefinitionAutoGenerated) UnmarshalJSON ¶ added in v0.6.0
func (e *ErrorDefinitionAutoGenerated) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDefinitionAutoGenerated.
type ErrorDefinitionAutoGenerated2 ¶
type ErrorDefinitionAutoGenerated2 struct { // READ-ONLY; Additional scenario specific error details. AdditionalInfo []*TypedErrorInfo // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. Code *string // READ-ONLY; Internal error details. Details []*ErrorDefinitionAutoGenerated2 // READ-ONLY; Description of the error. Message *string // READ-ONLY; The target of the error. Target *string }
ErrorDefinitionAutoGenerated2 - Error definition.
func (ErrorDefinitionAutoGenerated2) MarshalJSON ¶
func (e ErrorDefinitionAutoGenerated2) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ErrorDefinitionAutoGenerated2.
func (*ErrorDefinitionAutoGenerated2) UnmarshalJSON ¶ added in v0.6.0
func (e *ErrorDefinitionAutoGenerated2) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDefinitionAutoGenerated2.
type ErrorResponse ¶
type ErrorResponse struct { // The error details. Error *ErrorDefinition }
ErrorResponse - Error response.
func (ErrorResponse) MarshalJSON ¶ added in v0.6.0
func (e ErrorResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ErrorResponse.
func (*ErrorResponse) UnmarshalJSON ¶ added in v0.6.0
func (e *ErrorResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse.
type ErrorResponseAutoGenerated ¶
type ErrorResponseAutoGenerated struct { // The error details. Error *ErrorDefinitionAutoGenerated }
ErrorResponseAutoGenerated - Error response.
func (ErrorResponseAutoGenerated) MarshalJSON ¶ added in v0.6.0
func (e ErrorResponseAutoGenerated) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ErrorResponseAutoGenerated.
func (*ErrorResponseAutoGenerated) UnmarshalJSON ¶ added in v0.6.0
func (e *ErrorResponseAutoGenerated) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseAutoGenerated.
type ErrorResponseAutoGenerated2 ¶
type ErrorResponseAutoGenerated2 struct { // The error details. Error *ErrorDefinitionAutoGenerated2 }
ErrorResponseAutoGenerated2 - Error response.
func (ErrorResponseAutoGenerated2) MarshalJSON ¶ added in v0.6.0
func (e ErrorResponseAutoGenerated2) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ErrorResponseAutoGenerated2.
func (*ErrorResponseAutoGenerated2) UnmarshalJSON ¶ added in v0.6.0
func (e *ErrorResponseAutoGenerated2) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseAutoGenerated2.
type ExpressionEvaluationDetails ¶
type ExpressionEvaluationDetails struct { // Expression evaluated. Expression *string // Value of the expression. ExpressionValue any // Operator to compare the expression value and the target value. Operator *string // Property path if the expression is a field or an alias. Path *string // Evaluation result. Result *string // Target value to be compared with the expression value. TargetValue any // READ-ONLY; The kind of expression that was evaluated. ExpressionKind *string }
ExpressionEvaluationDetails - Evaluation details of policy language expressions.
func (ExpressionEvaluationDetails) MarshalJSON ¶ added in v0.6.0
func (e ExpressionEvaluationDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type ExpressionEvaluationDetails.
func (*ExpressionEvaluationDetails) UnmarshalJSON ¶ added in v0.6.0
func (e *ExpressionEvaluationDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type ExpressionEvaluationDetails.
type FieldRestriction ¶
type FieldRestriction struct { // READ-ONLY; The value that policy will set for the field if the user does not provide a value. DefaultValue *string // READ-ONLY; The details of the policy that is causing the field restriction. Policy *PolicyReference // READ-ONLY; The type of restriction that is imposed on the field. Result *FieldRestrictionResult // READ-ONLY; The values that policy either requires or denies for the field. Values []*string }
FieldRestriction - The restrictions on a field imposed by a specific policy.
func (FieldRestriction) MarshalJSON ¶
func (f FieldRestriction) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type FieldRestriction.
func (*FieldRestriction) UnmarshalJSON ¶ added in v0.6.0
func (f *FieldRestriction) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type FieldRestriction.
type FieldRestrictionResult ¶
type FieldRestrictionResult string
FieldRestrictionResult - The type of restriction that is imposed on the field.
const ( // FieldRestrictionResultDeny - The field and/or values will be denied by policy. FieldRestrictionResultDeny FieldRestrictionResult = "Deny" // FieldRestrictionResultRemoved - The field will be removed by policy. FieldRestrictionResultRemoved FieldRestrictionResult = "Removed" // FieldRestrictionResultRequired - The field and/or values are required by policy. FieldRestrictionResultRequired FieldRestrictionResult = "Required" )
func PossibleFieldRestrictionResultValues ¶
func PossibleFieldRestrictionResultValues() []FieldRestrictionResult
PossibleFieldRestrictionResultValues returns the possible values for the FieldRestrictionResult const type.
type FieldRestrictions ¶
type FieldRestrictions struct { // The restrictions placed on that field by policy. Restrictions []*FieldRestriction // READ-ONLY; The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias. Field *string }
FieldRestrictions - The restrictions that will be placed on a field in the resource by policy.
func (FieldRestrictions) MarshalJSON ¶
func (f FieldRestrictions) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type FieldRestrictions.
func (*FieldRestrictions) UnmarshalJSON ¶ added in v0.6.0
func (f *FieldRestrictions) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type FieldRestrictions.
type IfNotExistsEvaluationDetails ¶
type IfNotExistsEvaluationDetails struct { // ID of the last evaluated resource for IfNotExists effect. ResourceID *string // Total number of resources to which the existence condition is applicable. TotalResources *int32 }
IfNotExistsEvaluationDetails - Evaluation details of IfNotExists effect.
func (IfNotExistsEvaluationDetails) MarshalJSON ¶ added in v0.6.0
func (i IfNotExistsEvaluationDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type IfNotExistsEvaluationDetails.
func (*IfNotExistsEvaluationDetails) UnmarshalJSON ¶ added in v0.6.0
func (i *IfNotExistsEvaluationDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type IfNotExistsEvaluationDetails.
type Operation ¶
type Operation struct { // Display metadata associated with the operation. Display *OperationDisplay // Operation name. Name *string }
Operation definition.
func (Operation) MarshalJSON ¶ added in v0.6.0
MarshalJSON implements the json.Marshaller interface for type Operation.
func (*Operation) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON implements the json.Unmarshaller interface for type Operation.
type OperationDisplay ¶
type OperationDisplay struct { // Operation description. Description *string // Operation name. Operation *string // Resource provider name. Provider *string // Resource name on which the operation is performed. Resource *string }
OperationDisplay - Display metadata associated with the operation.
func (OperationDisplay) MarshalJSON ¶ added in v0.6.0
func (o OperationDisplay) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type OperationDisplay.
func (*OperationDisplay) UnmarshalJSON ¶ added in v0.6.0
func (o *OperationDisplay) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay.
type OperationsClient ¶
type OperationsClient struct {
// contains filtered or unexported fields
}
OperationsClient contains the methods for the Operations group. Don't use this type directly, use NewOperationsClient() instead.
func NewOperationsClient ¶
func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error)
NewOperationsClient creates a new instance of OperationsClient with the specified values.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*OperationsClient) List ¶
func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error)
List - Lists available operations. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_ListOperations.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewOperationsClient().List(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.OperationsListResults = armpolicyinsights.OperationsListResults{ // ODataCount: to.Ptr[int32](3), // Value: []*armpolicyinsights.Operation{ // { // Name: to.Ptr("Microsoft.PolicyInsights/policyEvents/queryResults/action"), // Display: &armpolicyinsights.OperationDisplay{ // Description: to.Ptr("Query information about policy events."), // Operation: to.Ptr("Query Policy Events"), // Provider: to.Ptr("Microsoft Policy Insights"), // Resource: to.Ptr("Policy Events"), // }, // }, // { // Name: to.Ptr("Microsoft.PolicyInsights/policyStates/queryResults/action"), // Display: &armpolicyinsights.OperationDisplay{ // Description: to.Ptr("Query information about policy states."), // Operation: to.Ptr("Query Policy States"), // Provider: to.Ptr("Microsoft Policy Insights"), // Resource: to.Ptr("Policy States"), // }, // }, // { // Name: to.Ptr("Microsoft.PolicyInsights/policyStates/summarize/action"), // Display: &armpolicyinsights.OperationDisplay{ // Description: to.Ptr("Query summary information about policy latest states."), // Operation: to.Ptr("Query Policy Latest States Summary"), // Provider: to.Ptr("Microsoft Policy Insights"), // Resource: to.Ptr("Policy States"), // }, // }}, // } }
Output:
type OperationsClientListOptions ¶
type OperationsClientListOptions struct { }
OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.
type OperationsClientListResponse ¶
type OperationsClientListResponse struct { // List of available operations. OperationsListResults }
OperationsClientListResponse contains the response from method OperationsClient.List.
type OperationsListResults ¶
type OperationsListResults struct { // OData entity count; represents the number of operations returned. ODataCount *int32 // List of available operations. Value []*Operation }
OperationsListResults - List of available operations.
func (OperationsListResults) MarshalJSON ¶
func (o OperationsListResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type OperationsListResults.
func (*OperationsListResults) UnmarshalJSON ¶ added in v0.6.0
func (o *OperationsListResults) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type OperationsListResults.
type PendingField ¶
type PendingField struct { // REQUIRED; The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias. Field *string // The list of potential values for the field that should be evaluated against Azure Policy. Values []*string }
PendingField - A field that should be evaluated against Azure Policy to determine restrictions.
func (PendingField) MarshalJSON ¶
func (p PendingField) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PendingField.
func (*PendingField) UnmarshalJSON ¶ added in v0.6.0
func (p *PendingField) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PendingField.
type PolicyAssignmentSummary ¶
type PolicyAssignmentSummary struct { // Policy assignment ID. PolicyAssignmentID *string // Policy definitions summary. PolicyDefinitions []*PolicyDefinitionSummary // Policy definition group summary. PolicyGroups []*PolicyGroupSummary // Policy set definition ID, if the policy assignment is for a policy set. PolicySetDefinitionID *string // Compliance summary for the policy assignment. Results *SummaryResults }
PolicyAssignmentSummary - Policy assignment summary.
func (PolicyAssignmentSummary) MarshalJSON ¶
func (p PolicyAssignmentSummary) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyAssignmentSummary.
func (*PolicyAssignmentSummary) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyAssignmentSummary) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyAssignmentSummary.
type PolicyDefinitionSummary ¶
type PolicyDefinitionSummary struct { // Policy effect, i.e. policy definition action. Effect *string // Policy definition group names. PolicyDefinitionGroupNames []*string // Policy definition ID. PolicyDefinitionID *string // Policy definition reference ID. PolicyDefinitionReferenceID *string // Compliance summary for the policy definition. Results *SummaryResults }
PolicyDefinitionSummary - Policy definition summary.
func (PolicyDefinitionSummary) MarshalJSON ¶
func (p PolicyDefinitionSummary) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyDefinitionSummary.
func (*PolicyDefinitionSummary) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyDefinitionSummary) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDefinitionSummary.
type PolicyDetails ¶
type PolicyDetails struct { // READ-ONLY; The display name of the policy assignment. PolicyAssignmentDisplayName *string // READ-ONLY; The ID of the policy assignment. PolicyAssignmentID *string // READ-ONLY; The scope of the policy assignment. PolicyAssignmentScope *string // READ-ONLY; The ID of the policy definition. PolicyDefinitionID *string // READ-ONLY; The policy definition reference ID within the policy set definition. PolicyDefinitionReferenceID *string // READ-ONLY; The ID of the policy set definition. PolicySetDefinitionID *string }
PolicyDetails - The policy details.
func (PolicyDetails) MarshalJSON ¶ added in v0.6.0
func (p PolicyDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyDetails.
func (*PolicyDetails) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDetails.
type PolicyEvaluationDetails ¶
type PolicyEvaluationDetails struct { // Details of the evaluated expressions. EvaluatedExpressions []*ExpressionEvaluationDetails // Evaluation details of IfNotExists effect. IfNotExistsDetails *IfNotExistsEvaluationDetails }
PolicyEvaluationDetails - Policy evaluation details.
func (PolicyEvaluationDetails) MarshalJSON ¶
func (p PolicyEvaluationDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyEvaluationDetails.
func (*PolicyEvaluationDetails) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyEvaluationDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyEvaluationDetails.
type PolicyEvaluationResult ¶
type PolicyEvaluationResult struct { // READ-ONLY; The detailed results of the policy expressions and values that were evaluated. EvaluationDetails *PolicyEvaluationDetails // READ-ONLY; The result of the policy evaluation against the resource. This will typically be 'NonCompliant' but may contain // other values if errors were encountered. EvaluationResult *string // READ-ONLY; The details of the policy that was evaluated. PolicyInfo *PolicyReference }
PolicyEvaluationResult - The result of a non-compliant policy evaluation against the given resource content.
func (PolicyEvaluationResult) MarshalJSON ¶ added in v0.6.0
func (p PolicyEvaluationResult) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyEvaluationResult.
func (*PolicyEvaluationResult) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyEvaluationResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyEvaluationResult.
type PolicyEvent ¶
type PolicyEvent struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. AdditionalProperties map[string]any // Compliance state of the resource. ComplianceState *string // Components events records populated only when URL contains $expand=components clause. Components []*ComponentEventDetails // Effective parameters for the policy assignment. EffectiveParameters *string // Flag which states whether the resource is compliant against the policy assignment it was evaluated against. IsCompliant *bool // Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. ManagementGroupIDs *string // OData context string; used by OData clients to resolve type information based on metadata. ODataContext *string // OData entity ID; always set to null since policy event records do not have an entity ID. ODataID *string // Policy assignment ID. PolicyAssignmentID *string // Policy assignment name. PolicyAssignmentName *string // Policy assignment owner. PolicyAssignmentOwner *string // Policy assignment parameters. PolicyAssignmentParameters *string // Policy assignment scope. PolicyAssignmentScope *string // Policy definition action, i.e. effect. PolicyDefinitionAction *string // Policy definition category. PolicyDefinitionCategory *string // Policy definition ID. PolicyDefinitionID *string // Policy definition name. PolicyDefinitionName *string // Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. PolicyDefinitionReferenceID *string // Policy set definition category, if the policy assignment is for a policy set. PolicySetDefinitionCategory *string // Policy set definition ID, if the policy assignment is for a policy set. PolicySetDefinitionID *string // Policy set definition name, if the policy assignment is for a policy set. PolicySetDefinitionName *string // Policy set definition owner, if the policy assignment is for a policy set. PolicySetDefinitionOwner *string // Policy set definition parameters, if the policy assignment is for a policy set. PolicySetDefinitionParameters *string // Principal object ID for the user who initiated the resource operation that triggered the policy event. PrincipalOid *string // Resource group name. ResourceGroup *string // Resource ID. ResourceID *string // Resource location. ResourceLocation *string // List of resource tags. ResourceTags *string // Resource type. ResourceType *string // Subscription ID. SubscriptionID *string // Tenant ID for the policy event record. TenantID *string // Timestamp for the policy event record. Timestamp *time.Time }
PolicyEvent - Policy event record.
func (PolicyEvent) MarshalJSON ¶
func (p PolicyEvent) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyEvent.
func (*PolicyEvent) UnmarshalJSON ¶
func (p *PolicyEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyEvent.
type PolicyEventsClient ¶
type PolicyEventsClient struct {
// contains filtered or unexported fields
}
PolicyEventsClient contains the methods for the PolicyEvents group. Don't use this type directly, use NewPolicyEventsClient() instead.
func NewPolicyEventsClient ¶
func NewPolicyEventsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyEventsClient, error)
NewPolicyEventsClient creates a new instance of PolicyEventsClient with the specified values.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*PolicyEventsClient) NewListQueryResultsForManagementGroupPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForManagementGroupPager(policyEventsResource PolicyEventsResourceType, managementGroupName string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForManagementGroupOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForManagementGroupResponse]
NewListQueryResultsForManagementGroupPager - Queries policy events for the resources under the management group.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- managementGroupName - Management group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForManagementGroupOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForManagementGroupPager method.
Example (QueryAtManagementGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForManagementGroupPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "myManagementGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/1ef5d536aec743a0aa801c1a"), // PolicyAssignmentName: to.Ptr("1ef5d536aec743a0aa801c1a"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr("15521232277412542086"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // PolicySetDefinitionName: to.Ptr("335cefd2-ab16-430f-b364-974a170eb1d5"), // PrincipalOid: to.Ptr("fff3e452-fff2-fff1-fff8-fff12618f1b8"), // ResourceGroup: to.Ptr("myrg"), // ResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myrg/providers/Microsoft.Compute/virtualMachines/myvm1/extensions/DAExtension"), // ResourceLocation: to.Ptr("westeurope"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Compute/virtualMachines/extensions"), // SubscriptionID: to.Ptr("fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T22:19:18.889Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/95816fce53454b15a7ed803d"), // PolicyAssignmentName: to.Ptr("95816fce53454b15a7ed803d"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"eastus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/a2c0414b-82e4-459d-97d5-94c79a89232c"), // PolicyDefinitionName: to.Ptr("a2c0414b-82e4-459d-97d5-94c79a89232c"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // PrincipalOid: to.Ptr("fff3e452-fff2-fff1-fff8-fff12618f1b8"), // ResourceGroup: to.Ptr("myrg"), // ResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myrg/providers/Microsoft.Compute/virtualMachines/myvm1/extensions/DAExtension"), // ResourceLocation: to.Ptr("westeurope"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Compute/virtualMachines/extensions"), // SubscriptionID: to.Ptr("fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T22:19:18.889Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtManagementGroupScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForManagementGroupPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "myManagementGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/1ef5d536aec743a0aa801c1a"), // PolicyAssignmentName: to.Ptr("1ef5d536aec743a0aa801c1a"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr("15521232277412542086"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // PolicySetDefinitionName: to.Ptr("335cefd2-ab16-430f-b364-974a170eb1d5"), // PrincipalOid: to.Ptr("fff3e452-fff2-fff1-fff8-fff12618f1b8"), // ResourceGroup: to.Ptr("myrg"), // ResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myrg/providers/Microsoft.Compute/virtualMachines/myvm1/extensions/DAExtension"), // ResourceLocation: to.Ptr("westeurope"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Compute/virtualMachines/extensions"), // SubscriptionID: to.Ptr("fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T22:19:18.889Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/95816fce53454b15a7ed803d"), // PolicyAssignmentName: to.Ptr("95816fce53454b15a7ed803d"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"eastus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/a2c0414b-82e4-459d-97d5-94c79a89232c"), // PolicyDefinitionName: to.Ptr("a2c0414b-82e4-459d-97d5-94c79a89232c"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // PrincipalOid: to.Ptr("fff3e452-fff2-fff1-fff8-fff12618f1b8"), // ResourceGroup: to.Ptr("myrg"), // ResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myrg/providers/Microsoft.Compute/virtualMachines/myvm1/extensions/DAExtension"), // ResourceLocation: to.Ptr("westeurope"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Compute/virtualMachines/extensions"), // SubscriptionID: to.Ptr("fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T22:19:18.889Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForPolicyDefinitionPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForPolicyDefinitionPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, policyDefinitionName string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForPolicyDefinitionOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForPolicyDefinitionResponse]
NewListQueryResultsForPolicyDefinitionPager - Queries policy events for the subscription level policy definition.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- subscriptionID - Microsoft Azure subscription ID.
- policyDefinitionName - Policy definition name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForPolicyDefinitionOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForPolicyDefinitionPager method.
Example (QueryAtSubscriptionLevelPolicyDefinitionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForPolicyDefinitionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "24813039-7534-408a-9842-eb99f45721b1", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/f4cc58b7db524a9799381531"), // PolicyAssignmentName: to.Ptr("f4cc58b7db524a9799381531"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"NA\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("14799174781370023846"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/deploymentSlots/production/state/start"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/deploymentSlots/state"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:58:11.590Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/f4cc58b7db524a9799381531"), // PolicyAssignmentName: to.Ptr("f4cc58b7db524a9799381531"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"NA\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("1679708035638239273"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/deploymentSlots/production/state/start"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/deploymentSlots/state"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:58:11.590Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtSubscriptionLevelPolicyDefinitionScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForPolicyDefinitionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "24813039-7534-408a-9842-eb99f45721b1", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/f4cc58b7db524a9799381531"), // PolicyAssignmentName: to.Ptr("f4cc58b7db524a9799381531"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"NA\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("14799174781370023846"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/deploymentSlots/production/state/start"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/deploymentSlots/state"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:58:11.590Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/f4cc58b7db524a9799381531"), // PolicyAssignmentName: to.Ptr("f4cc58b7db524a9799381531"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"NA\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("1679708035638239273"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/deploymentSlots/production/state/start"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/deploymentSlots/state"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:58:11.590Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForPolicySetDefinitionPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForPolicySetDefinitionPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, policySetDefinitionName string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForPolicySetDefinitionOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse]
NewListQueryResultsForPolicySetDefinitionPager - Queries policy events for the subscription level policy set definition.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- subscriptionID - Microsoft Azure subscription ID.
- policySetDefinitionName - Policy set definition name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForPolicySetDefinitionOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForPolicySetDefinitionPager method.
Example (QueryAtSubscriptionLevelPolicySetDefinitionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForPolicySetDefinitionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "3e3807c1-65c9-49e0-a406-82d8ae3e338c", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/serviceCertificates/sha1-FFFBDAF1FFFF109FFFD95FFFC9B0FFFD6F264FFF"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/serviceCertificates"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:49:32.953Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/serviceCertificates/sha1-FFF36C1CFFF4BEA57FFFEFCFFF17B9F81B710FFF"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/serviceCertificates"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:49:32.949Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtSubscriptionLevelPolicySetDefinitionScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForPolicySetDefinitionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "3e3807c1-65c9-49e0-a406-82d8ae3e338c", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/serviceCertificates/sha1-FFFBDAF1FFFF109FFFD95FFFC9B0FFFD6F264FFF"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/serviceCertificates"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:49:32.953Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/serviceCertificates/sha1-FFF36C1CFFF4BEA57FFFEFCFFF17B9F81B710FFF"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames/serviceCertificates"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:49:32.949Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, resourceGroupName string, policyAssignmentName string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse]
NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager - Queries policy events for the resource group level policy assignment.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- policyAssignmentName - Policy assignment name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager method.
Example (QueryAtResourceGroupLevelPolicyAssignmentScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", "myPolicyAssignment", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup"), // PolicyDefinitionAction: to.Ptr("deny"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyDefinitions/myPolicyDefinition"), // PolicyDefinitionName: to.Ptr("myPolicyAssignment"), // PrincipalOid: to.Ptr("fff2f355-fff2-fffc-fffb-fff1639dff94"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/defaultworkspace-fffedd8f-ffff-fffd-fffd-fffed2f84852-eus"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.operationalinsights/workspaces"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T00:07:16.280Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup"), // PolicyDefinitionAction: to.Ptr("deny"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyDefinitions/myPolicyDefinition"), // PolicyDefinitionName: to.Ptr("myPolicyAssignment"), // PrincipalOid: to.Ptr("fff2f355-fff2-fffc-fffb-fff1639dff94"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/defaultworkspace-fffedd8f-ffff-fffd-fffd-fffed2f84852-eus"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.operationalinsights/workspaces"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T00:06:08.430Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtResourceGroupLevelPolicyAssignmentScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", "myPolicyAssignment", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup"), // PolicyDefinitionAction: to.Ptr("deny"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyDefinitions/myPolicyDefinition"), // PolicyDefinitionName: to.Ptr("myPolicyAssignment"), // PrincipalOid: to.Ptr("fff2f355-fff2-fffc-fffb-fff1639dff94"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/defaultworkspace-fffedd8f-ffff-fffd-fffd-fffed2f84852-eus"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.operationalinsights/workspaces"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T00:07:16.280Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup"), // PolicyDefinitionAction: to.Ptr("deny"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyDefinitions/myPolicyDefinition"), // PolicyDefinitionName: to.Ptr("myPolicyAssignment"), // PrincipalOid: to.Ptr("fff2f355-fff2-fffc-fffb-fff1639dff94"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/defaultworkspace-fffedd8f-ffff-fffd-fffd-fffed2f84852-eus"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.operationalinsights/workspaces"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T00:06:08.430Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForResourceGroupPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForResourceGroupPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, resourceGroupName string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForResourceGroupOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForResourceGroupResponse]
NewListQueryResultsForResourceGroupPager - Queries policy events for the resources under the resource group.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForResourceGroupOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForResourceGroupPager method.
Example (QueryAtResourceGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourceGroupPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("181565554491747128"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("624540685646900425"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtResourceGroupScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourceGroupPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("181565554491747128"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("624540685646900425"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForResourcePager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForResourcePager(policyEventsResource PolicyEventsResourceType, resourceID string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForResourceOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForResourceResponse]
NewListQueryResultsForResourcePager - Queries policy events for the resource.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- resourceID - Resource ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForResourceOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForResourcePager method.
Example (QueryAtNestedResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryNestedResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/microsoft.servicefabric/clusters/myCluster/applications/myApplication/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/microsoft.servicefabric/clusters/myCluster/applications/myApplication/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("181565554491747128"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/microsoft.servicefabric/clusters/myCluster/applications/myApplication/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("624540685646900425"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T15:14:39.847Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/d15545b8-ff50-409a-a6e3-5bd5cc954003"), // PolicyAssignmentName: to.Ptr("d15545b8-ff50-409a-a6e3-5bd5cc954003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T15:14:39.584Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtResourceScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T15:14:39.847Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/d15545b8-ff50-409a-a6e3-5bd5cc954003"), // PolicyAssignmentName: to.Ptr("d15545b8-ff50-409a-a6e3-5bd5cc954003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T15:14:39.584Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtSubscriptionLevelNestedResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelNestedResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("181565554491747128"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType/someNestedResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("624540685646900425"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType/someNestedResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtSubscriptionLevelResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T15:14:39.847Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/d15545b8-ff50-409a-a6e3-5bd5cc954003"), // PolicyAssignmentName: to.Ptr("d15545b8-ff50-409a-a6e3-5bd5cc954003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T15:14:39.584Z"); return t}()), // }}, // } } }
Output:
Example (QueryComponentsPolicyEventsCountGroupedByUserAndActionTypeForResourceScopeFilteredByGivenAssignment) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponentsGroupByWithAggregate.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", &armpolicyinsights.QueryOptions{Top: nil, Filter: to.Ptr("policyAssignmentId eq '/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: to.Ptr("components($apply=groupby((tenantId, principalOid, policyDefinitionAction), aggregate($count as totalActions)))"), }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // Components: []*armpolicyinsights.ComponentEventDetails{ // { // AdditionalProperties: map[string]any{ // "totalActions": float64(6), // }, // PolicyDefinitionAction: to.Ptr("audit"), // PrincipalOid: to.Ptr("0d81b461-6bb0-4909-a102-d51803a7d275"), // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), // }}, // EffectiveParameters: to.Ptr(""), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("PolicyUIMG,AzGovTest5,72f988bf-86f1-41af-91ab-2d7cd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8"), // PolicyAssignmentName: to.Ptr("560050f83dbb4a24974323f8"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr(""), // PolicyAssignmentScope: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policydefinitions/ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionName: to.Ptr("ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionCategory: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // PolicySetDefinitionOwner: to.Ptr(""), // PolicySetDefinitionParameters: to.Ptr(""), // PrincipalOid: to.Ptr(""), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName"), // ResourceLocation: to.Ptr("westcentralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("Microsoft.KeyVault/vaults"), // SubscriptionID: to.Ptr("e78961ba-36fe-4739-9212-e3031b4c8db7"), // TenantID: to.Ptr(""), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T19:42:08.325Z"); return t}()), // }}, // } } }
Output:
Example (QueryComponentsPolicyEventsForResourceScopeFilteredByGivenAssignment) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponents.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyEventsResourceTypeDefault, "subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", &armpolicyinsights.QueryOptions{Top: nil, Filter: to.Ptr("policyAssignmentId eq '/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: to.Ptr("components"), }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // Components: []*armpolicyinsights.ComponentEventDetails{ // { // Name: to.Ptr("cert-RSA-cert-3"), // Type: to.Ptr("Certificate"), // ID: to.Ptr("cert-RSA-cert-3"), // PolicyDefinitionAction: to.Ptr("audit"), // PrincipalOid: to.Ptr("0d81b461-6bb0-4909-a102-d51803a7d275"), // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:23.036Z"); return t}()), // }, // { // Name: to.Ptr("cert-RSA-cert-2"), // Type: to.Ptr("Certificate"), // ID: to.Ptr("cert-RSA-cert-2"), // PolicyDefinitionAction: to.Ptr("audit"), // PrincipalOid: to.Ptr("0d81b461-6bb0-4909-a102-d51803a7d275"), // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:22.768Z"); return t}()), // }}, // EffectiveParameters: to.Ptr(""), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("PolicyUIMG,AzGovTest5,72f988bf-86f1-41af-91ab-2d7cd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8"), // PolicyAssignmentName: to.Ptr("560050f83dbb4a24974323f8"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr(""), // PolicyAssignmentScope: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policydefinitions/ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionName: to.Ptr("ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionCategory: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // PolicySetDefinitionOwner: to.Ptr(""), // PolicySetDefinitionParameters: to.Ptr(""), // PrincipalOid: to.Ptr(""), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName"), // ResourceLocation: to.Ptr("westcentralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("Microsoft.KeyVault/vaults"), // SubscriptionID: to.Ptr("e78961ba-36fe-4739-9212-e3031b4c8db7"), // TenantID: to.Ptr(""), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T19:42:08.325Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, policyAssignmentName string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse]
NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager - Queries policy events for the subscription level policy assignment.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- subscriptionID - Microsoft Azure subscription ID.
- policyAssignmentName - Policy assignment name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager method.
Example (QueryAtSubscriptionLevelPolicyAssignmentScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "ec8f9645-8ecb-4abb-9c0b-5292f19d4003", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:59:38.640Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionName: to.Ptr("9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:59:34.201Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtSubscriptionLevelPolicyAssignmentScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "ec8f9645-8ecb-4abb-9c0b-5292f19d4003", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicyDefinitionName: to.Ptr("201ea587-7c90-41c3-910f-c280ae01cfd6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:59:38.640Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionName: to.Ptr("9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PrincipalOid: to.Ptr("fff890fa-fff0-fff3-fff9-fffd7653f078"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T19:59:34.201Z"); return t}()), // }}, // } } }
Output:
func (*PolicyEventsClient) NewListQueryResultsForSubscriptionPager ¶ added in v0.4.0
func (client *PolicyEventsClient) NewListQueryResultsForSubscriptionPager(policyEventsResource PolicyEventsResourceType, subscriptionID string, queryOptions *QueryOptions, options *PolicyEventsClientListQueryResultsForSubscriptionOptions) *runtime.Pager[PolicyEventsClientListQueryResultsForSubscriptionResponse]
NewListQueryResultsForSubscriptionPager - Queries policy events for the resources under the subscription.
Generated from API version 2019-10-01
- policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
- subscriptionID - Microsoft Azure subscription ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyEventsClientListQueryResultsForSubscriptionOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForSubscriptionPager method.
Example (FilterAndAggregateOnly) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndAggregateOnly.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: nil, Filter: to.Ptr("PolicyDefinitionAction eq 'deny'"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-05T18:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("aggregate($count as NumDenyEvents)"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.PolicyEvent{ // { // AdditionalProperties: map[string]any{ // "NumDenyEvents": float64(40), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // }}, // } } }
Output:
Example (FilterAndGroupWithAggregate) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndGroupByWithAggregate.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: to.Ptr("PolicyDefinitionAction eq 'audit' or PolicyDefinitionAction eq 'deny'"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-05T18:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("groupby((PolicyAssignmentId, PolicyDefinitionId, PolicyDefinitionAction, ResourceId), aggregate($count as NumEvents))"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // AdditionalProperties: map[string]any{ // "NumEvents": float64(1), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.servicefabric/clusters/myCluster/applications/resourcescachemonitor/services/myService"), // }, // { // AdditionalProperties: map[string]any{ // "NumEvents": float64(1), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d6be6bb37e5f4333baa95c2a"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/5948d091-78b7-4d3b-a404-cc6a0329b0c6"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.servicefabric/clusters/myCluster/applications/resourcescachemonitor/services/myService"), // }}, // } } }
Output:
Example (FilterAndGroupWithoutAggregate) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndGroupByWithoutAggregate.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: to.Ptr("PolicyDefinitionAction ne 'audit' and PolicyDefinitionAction ne 'append'"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-05T18:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("groupby((PolicyAssignmentId, PolicyDefinitionId, PolicyDefinitionAction, ResourceId))"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/5bc427ca-0089-4d0d-85bd-e98d1e40b3bf/providers/microsoft.authorization/policyassignments/storageaccountsku"), // PolicyDefinitionAction: to.Ptr("deny"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/5bc427ca-0089-4d0d-85bd-e98d1e40b3bf/providers/microsoft.storage/storageaccounts/7d528d3a"), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/da43b50031bf4bce84584faa"), // PolicyDefinitionAction: to.Ptr("deny"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/mysa1"), // }}, // } } }
Output:
Example (FilterAndMultipleGroups) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndMultipleGroups.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](10), Filter: to.Ptr("PolicyDefinitionAction eq 'deny'"), OrderBy: to.Ptr("NumDeniedResources desc"), Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("groupby((PolicyAssignmentId, PolicyDefinitionId, ResourceId))/groupby((PolicyAssignmentId, PolicyDefinitionId), aggregate($count as NumDeniedResources))"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](6), // Value: []*armpolicyinsights.PolicyEvent{ // { // AdditionalProperties: map[string]any{ // "NumDeniedResources": float64(3), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup1/providers/microsoft.authorization/policyassignments/0591f497c35344fcbaf7a393"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/e56962a6-4747-49cd-b67b-bf8b01975c4c"), // }, // { // AdditionalProperties: map[string]any{ // "NumDeniedResources": float64(2), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup1/providers/microsoft.authorization/policyassignments/myassignment1"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/mydefinition1"), // }, // { // AdditionalProperties: map[string]any{ // "NumDeniedResources": float64(2), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup1/providers/microsoft.authorization/policyassignments/myassignment1"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/mydefinition2"), // }, // { // AdditionalProperties: map[string]any{ // "NumDeniedResources": float64(1), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/5bc427ca-0089-4d0d-85bd-e98d1e40b3bf/providers/microsoft.authorization/policyassignments/storageaccountsku"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), // }, // { // AdditionalProperties: map[string]any{ // "NumDeniedResources": float64(1), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup2/providers/microsoft.authorization/policyassignments/da43b50031bf4bce84584faa"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62"), // }, // { // AdditionalProperties: map[string]any{ // "NumDeniedResources": float64(1), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup2/providers/microsoft.authorization/policyassignments/myassignment2"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/mydefinition3"), // }}, // } } }
Output:
Example (QueryAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("181565554491747128"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("624540685646900425"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }}, // } } }
Output:
Example (QueryAtSubscriptionScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("181565554491747128"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/ec62f9b2a454487296f2ccd4"), // PolicyAssignmentName: to.Ptr("ec62f9b2a454487296f2ccd4"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"ALLOWEDRESOURCEGROUPS_1\":{\"value\":[\"rg1\",\"rg2\"]},\"ALLOWEDRESOURCEGROUPS_2\":{\"value\":[\"myrg3\",\"myrg4\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionName: to.Ptr("72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr("624540685646900425"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/00b36c66-612b-44e2-9f8e-b758296d40fe"), // PolicySetDefinitionName: to.Ptr("00b36c66-612b-44e2-9f8e-b758296d40fe"), // PrincipalOid: to.Ptr("fffdfc0f-fff5-fff0-fff3-fff1a968dcc6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // TenantID: to.Ptr("fff988bf-fff1-ffff-fffb-fffcd011db47"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-07T20:43:04.697Z"); return t}()), // }}, // } } }
Output:
Example (TimeRangeSortSelectAndLimit) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_TimeRangeSortSelectTop.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyEventsClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyEventsResourceTypeDefault, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: nil, OrderBy: to.Ptr("Timestamp desc, PolicyAssignmentId asc, SubscriptionId asc, ResourceGroup asc, ResourceId"), Select: to.Ptr("Timestamp, PolicyAssignmentId, PolicyDefinitionId, SubscriptionId, ResourceGroup, ResourceId"), From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-05T18:00:00.000Z"); return t }()), To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-06T18:00:00.000Z"); return t }()), Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyEventsQueryResults = armpolicyinsights.PolicyEventsQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyEvent{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/89b27f38-e9e4-4468-ab81-801c84b8c017"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomain"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-05T22:34:02.347Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyEvents/$metadata#default/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/Enable Monitoring in Azure Security Center"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomain"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-05T22:34:01.613Z"); return t}()), // }}, // } } }
Output:
type PolicyEventsClientListQueryResultsForManagementGroupOptions ¶
type PolicyEventsClientListQueryResultsForManagementGroupOptions struct { }
PolicyEventsClientListQueryResultsForManagementGroupOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForManagementGroupPager method.
type PolicyEventsClientListQueryResultsForManagementGroupResponse ¶
type PolicyEventsClientListQueryResultsForManagementGroupResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForManagementGroupResponse contains the response from method PolicyEventsClient.NewListQueryResultsForManagementGroupPager.
type PolicyEventsClientListQueryResultsForPolicyDefinitionOptions ¶
type PolicyEventsClientListQueryResultsForPolicyDefinitionOptions struct { }
PolicyEventsClientListQueryResultsForPolicyDefinitionOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForPolicyDefinitionPager method.
type PolicyEventsClientListQueryResultsForPolicyDefinitionResponse ¶
type PolicyEventsClientListQueryResultsForPolicyDefinitionResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForPolicyDefinitionResponse contains the response from method PolicyEventsClient.NewListQueryResultsForPolicyDefinitionPager.
type PolicyEventsClientListQueryResultsForPolicySetDefinitionOptions ¶
type PolicyEventsClientListQueryResultsForPolicySetDefinitionOptions struct { }
PolicyEventsClientListQueryResultsForPolicySetDefinitionOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForPolicySetDefinitionPager method.
type PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse ¶
type PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse contains the response from method PolicyEventsClient.NewListQueryResultsForPolicySetDefinitionPager.
type PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions ¶
type PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions struct { }
PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager method.
type PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse ¶
type PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse contains the response from method PolicyEventsClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager.
type PolicyEventsClientListQueryResultsForResourceGroupOptions ¶
type PolicyEventsClientListQueryResultsForResourceGroupOptions struct { }
PolicyEventsClientListQueryResultsForResourceGroupOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForResourceGroupPager method.
type PolicyEventsClientListQueryResultsForResourceGroupResponse ¶
type PolicyEventsClientListQueryResultsForResourceGroupResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForResourceGroupResponse contains the response from method PolicyEventsClient.NewListQueryResultsForResourceGroupPager.
type PolicyEventsClientListQueryResultsForResourceOptions ¶
type PolicyEventsClientListQueryResultsForResourceOptions struct { }
PolicyEventsClientListQueryResultsForResourceOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForResourcePager method.
type PolicyEventsClientListQueryResultsForResourceResponse ¶
type PolicyEventsClientListQueryResultsForResourceResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForResourceResponse contains the response from method PolicyEventsClient.NewListQueryResultsForResourcePager.
type PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions ¶
type PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions struct { }
PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager method.
type PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse ¶
type PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse contains the response from method PolicyEventsClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager.
type PolicyEventsClientListQueryResultsForSubscriptionOptions ¶
type PolicyEventsClientListQueryResultsForSubscriptionOptions struct { }
PolicyEventsClientListQueryResultsForSubscriptionOptions contains the optional parameters for the PolicyEventsClient.NewListQueryResultsForSubscriptionPager method.
type PolicyEventsClientListQueryResultsForSubscriptionResponse ¶
type PolicyEventsClientListQueryResultsForSubscriptionResponse struct { // Query results. PolicyEventsQueryResults }
PolicyEventsClientListQueryResultsForSubscriptionResponse contains the response from method PolicyEventsClient.NewListQueryResultsForSubscriptionPager.
type PolicyEventsQueryResults ¶
type PolicyEventsQueryResults struct { // OData context string; used by OData clients to resolve type information based on metadata. ODataContext *string // OData entity count; represents the number of policy event records returned. ODataCount *int32 // Odata next link; URL to get the next set of results. ODataNextLink *string // Query results. Value []*PolicyEvent }
PolicyEventsQueryResults - Query results.
func (PolicyEventsQueryResults) MarshalJSON ¶
func (p PolicyEventsQueryResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyEventsQueryResults.
func (*PolicyEventsQueryResults) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyEventsQueryResults) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyEventsQueryResults.
type PolicyEventsResourceType ¶ added in v0.2.0
type PolicyEventsResourceType string
const (
PolicyEventsResourceTypeDefault PolicyEventsResourceType = "default"
)
func PossiblePolicyEventsResourceTypeValues ¶ added in v0.2.0
func PossiblePolicyEventsResourceTypeValues() []PolicyEventsResourceType
PossiblePolicyEventsResourceTypeValues returns the possible values for the PolicyEventsResourceType const type.
type PolicyGroupSummary ¶
type PolicyGroupSummary struct { // Policy group name. PolicyGroupName *string // Compliance summary for the policy definition group. Results *SummaryResults }
PolicyGroupSummary - Policy definition group summary.
func (PolicyGroupSummary) MarshalJSON ¶ added in v0.6.0
func (p PolicyGroupSummary) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyGroupSummary.
func (*PolicyGroupSummary) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyGroupSummary) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyGroupSummary.
type PolicyMetadata ¶
type PolicyMetadata struct { // Properties of the policy metadata. Properties *PolicyMetadataProperties // READ-ONLY; The ID of the policy metadata. ID *string // READ-ONLY; The name of the policy metadata. Name *string // READ-ONLY; The type of the policy metadata. Type *string }
PolicyMetadata - Policy metadata resource definition.
func (PolicyMetadata) MarshalJSON ¶ added in v0.6.0
func (p PolicyMetadata) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyMetadata.
func (*PolicyMetadata) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyMetadata) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyMetadata.
type PolicyMetadataClient ¶
type PolicyMetadataClient struct {
// contains filtered or unexported fields
}
PolicyMetadataClient contains the methods for the PolicyMetadata group. Don't use this type directly, use NewPolicyMetadataClient() instead.
func NewPolicyMetadataClient ¶
func NewPolicyMetadataClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyMetadataClient, error)
NewPolicyMetadataClient creates a new instance of PolicyMetadataClient with the specified values.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*PolicyMetadataClient) GetResource ¶
func (client *PolicyMetadataClient) GetResource(ctx context.Context, resourceName string, options *PolicyMetadataClientGetResourceOptions) (PolicyMetadataClientGetResourceResponse, error)
GetResource - Get policy metadata resource. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- resourceName - The name of the policy metadata resource.
- options - PolicyMetadataClientGetResourceOptions contains the optional parameters for the PolicyMetadataClient.GetResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyMetadataClient().GetResource(ctx, "NIST_SP_800-53_R4_AC-2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.PolicyMetadata = armpolicyinsights.PolicyMetadata{ // Name: to.Ptr("NIST_SP_800-53_R4_AC-2"), // Type: to.Ptr("Microsoft.PolicyInsights/policyMetadata"), // ID: to.Ptr("/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2"), // Properties: &armpolicyinsights.PolicyMetadataProperties{ // AdditionalContentURL: to.Ptr("https://aka.ms/NIST_SP_800-53_R4_AC-2"), // Category: to.Ptr("Access control"), // Metadata: map[string]any{ // }, // MetadataID: to.Ptr("NIST SP 800-53 R4 AC-2"), // Owner: to.Ptr("Shared"), // Title: to.Ptr("Account Management"), // Description: to.Ptr("Description of NIST SP 800-53 R4 AC-2"), // Requirements: to.Ptr("List the requirements for NIST SP 800-53 R4 AC-2"), // }, // } }
Output:
func (*PolicyMetadataClient) NewListPager ¶ added in v0.4.0
func (client *PolicyMetadataClient) NewListPager(queryOptions *QueryOptions, options *PolicyMetadataClientListOptions) *runtime.Pager[PolicyMetadataClientListResponse]
NewListPager - Get a list of the policy metadata resources.
Generated from API version 2019-10-01
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyMetadataClientListOptions contains the optional parameters for the PolicyMetadataClient.NewListPager method.
Example (GetCollectionOfPolicyMetadataResources) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyMetadataClient().NewListPager(&armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyMetadataCollection = armpolicyinsights.PolicyMetadataCollection{ // Value: []*armpolicyinsights.SlimPolicyMetadata{ // { // Name: to.Ptr("NIST_SP_800-53_R4_AC-2"), // Type: to.Ptr("Microsoft.PolicyInsights/policyMetadata"), // ID: to.Ptr("/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2"), // Properties: &armpolicyinsights.PolicyMetadataSlimProperties{ // AdditionalContentURL: to.Ptr("https://aka.ms/NIST_SP_800-53_R4_AC-2"), // Category: to.Ptr("Access control"), // Metadata: map[string]any{ // }, // MetadataID: to.Ptr("NIST SP 800-53 R4 AC-2"), // Owner: to.Ptr("Shared"), // Title: to.Ptr("Account Management"), // }, // }}, // } } }
Output:
Example (GetCollectionOfPolicyMetadataResourcesUsingTopQueryParameter) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyMetadataClient().NewListPager(&armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyMetadataCollection = armpolicyinsights.PolicyMetadataCollection{ // Value: []*armpolicyinsights.SlimPolicyMetadata{ // { // Name: to.Ptr("NIST_SP_800-53_R4_AC-2"), // Type: to.Ptr("Microsoft.PolicyInsights/policyMetadata"), // ID: to.Ptr("/providers/Microsoft.PolicyInsights/policyMetadata/NIST_SP_800-53_R4_AC-2"), // Properties: &armpolicyinsights.PolicyMetadataSlimProperties{ // AdditionalContentURL: to.Ptr("https://aka.ms/NIST_SP_800-53_R4_AC-2"), // Category: to.Ptr("Access control"), // Metadata: map[string]any{ // }, // MetadataID: to.Ptr("NIST SP 800-53 R4 AC-2"), // Owner: to.Ptr("Shared"), // Title: to.Ptr("Account Management"), // }, // }}, // } } }
Output:
type PolicyMetadataClientGetResourceOptions ¶
type PolicyMetadataClientGetResourceOptions struct { }
PolicyMetadataClientGetResourceOptions contains the optional parameters for the PolicyMetadataClient.GetResource method.
type PolicyMetadataClientGetResourceResponse ¶
type PolicyMetadataClientGetResourceResponse struct { // Policy metadata resource definition. PolicyMetadata }
PolicyMetadataClientGetResourceResponse contains the response from method PolicyMetadataClient.GetResource.
type PolicyMetadataClientListOptions ¶
type PolicyMetadataClientListOptions struct { }
PolicyMetadataClientListOptions contains the optional parameters for the PolicyMetadataClient.NewListPager method.
type PolicyMetadataClientListResponse ¶
type PolicyMetadataClientListResponse struct { // Collection of policy metadata resources. PolicyMetadataCollection }
PolicyMetadataClientListResponse contains the response from method PolicyMetadataClient.NewListPager.
type PolicyMetadataCollection ¶
type PolicyMetadataCollection struct { // READ-ONLY; The URL to get the next set of results. NextLink *string // READ-ONLY; Array of policy metadata definitions. Value []*SlimPolicyMetadata }
PolicyMetadataCollection - Collection of policy metadata resources.
func (PolicyMetadataCollection) MarshalJSON ¶
func (p PolicyMetadataCollection) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyMetadataCollection.
func (*PolicyMetadataCollection) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyMetadataCollection) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyMetadataCollection.
type PolicyMetadataProperties ¶
type PolicyMetadataProperties struct { // READ-ONLY; Url for getting additional content about the resource metadata. AdditionalContentURL *string // READ-ONLY; The category of the policy metadata. Category *string // READ-ONLY; The description of the policy metadata. Description *string // READ-ONLY; Additional metadata. Metadata any // READ-ONLY; The policy metadata identifier. MetadataID *string // READ-ONLY; The owner of the policy metadata. Owner *string // READ-ONLY; The requirements of the policy metadata. Requirements *string // READ-ONLY; The title of the policy metadata. Title *string }
PolicyMetadataProperties - The properties of the policy metadata.
func (PolicyMetadataProperties) MarshalJSON ¶ added in v0.6.0
func (p PolicyMetadataProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyMetadataProperties.
func (*PolicyMetadataProperties) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyMetadataProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyMetadataProperties.
type PolicyMetadataSlimProperties ¶
type PolicyMetadataSlimProperties struct { // READ-ONLY; Url for getting additional content about the resource metadata. AdditionalContentURL *string // READ-ONLY; The category of the policy metadata. Category *string // READ-ONLY; Additional metadata. Metadata any // READ-ONLY; The policy metadata identifier. MetadataID *string // READ-ONLY; The owner of the policy metadata. Owner *string // READ-ONLY; The title of the policy metadata. Title *string }
PolicyMetadataSlimProperties - The properties of the policy metadata, excluding properties containing large strings
func (PolicyMetadataSlimProperties) MarshalJSON ¶ added in v0.6.0
func (p PolicyMetadataSlimProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyMetadataSlimProperties.
func (*PolicyMetadataSlimProperties) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyMetadataSlimProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyMetadataSlimProperties.
type PolicyReference ¶
type PolicyReference struct { // READ-ONLY; The resource identifier of the policy assignment. PolicyAssignmentID *string // READ-ONLY; The resource identifier of the policy definition. PolicyDefinitionID *string // READ-ONLY; The reference identifier of a specific policy definition within a policy set definition. PolicyDefinitionReferenceID *string // READ-ONLY; The resource identifier of the policy set definition. PolicySetDefinitionID *string }
PolicyReference - Resource identifiers for a policy.
func (PolicyReference) MarshalJSON ¶ added in v0.6.0
func (p PolicyReference) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyReference.
func (*PolicyReference) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyReference) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyReference.
type PolicyRestrictionsClient ¶
type PolicyRestrictionsClient struct {
// contains filtered or unexported fields
}
PolicyRestrictionsClient contains the methods for the PolicyRestrictions group. Don't use this type directly, use NewPolicyRestrictionsClient() instead.
func NewPolicyRestrictionsClient ¶
func NewPolicyRestrictionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyRestrictionsClient, error)
NewPolicyRestrictionsClient creates a new instance of PolicyRestrictionsClient with the specified values.
- subscriptionID - Microsoft Azure subscription ID.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*PolicyRestrictionsClient) CheckAtManagementGroupScope ¶ added in v0.3.0
func (client *PolicyRestrictionsClient) CheckAtManagementGroupScope(ctx context.Context, managementGroupID string, parameters CheckManagementGroupRestrictionsRequest, options *PolicyRestrictionsClientCheckAtManagementGroupScopeOptions) (PolicyRestrictionsClientCheckAtManagementGroupScopeResponse, error)
CheckAtManagementGroupScope - Checks what restrictions Azure Policy will place on resources within a management group. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-03-01
- managementGroupID - Management group ID.
- parameters - The check policy restrictions parameters.
- options - PolicyRestrictionsClientCheckAtManagementGroupScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtManagementGroupScope method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-03-01/examples/PolicyRestrictions_CheckAtManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyRestrictionsClient().CheckAtManagementGroupScope(ctx, "financeMg", armpolicyinsights.CheckManagementGroupRestrictionsRequest{ PendingFields: []*armpolicyinsights.PendingField{ { Field: to.Ptr("type"), }}, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.CheckRestrictionsResult = armpolicyinsights.CheckRestrictionsResult{ // ContentEvaluationResult: &armpolicyinsights.CheckRestrictionsResultContentEvaluationResult{ // PolicyEvaluations: []*armpolicyinsights.PolicyEvaluationResult{ // }, // }, // FieldRestrictions: []*armpolicyinsights.FieldRestrictions{ // { // Field: to.Ptr("type"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.authorization/policyAssignments/7EB1508A"), // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.authorization/policyDefinitions/allowedTypes"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.authorization/policySetDefinitions/735551F1"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultRequired), // Values: []*string{ // to.Ptr("Microsoft.Compute/virtualMachines")}, // }}, // }}, // } }
Output:
func (*PolicyRestrictionsClient) CheckAtResourceGroupScope ¶
func (client *PolicyRestrictionsClient) CheckAtResourceGroupScope(ctx context.Context, resourceGroupName string, parameters CheckRestrictionsRequest, options *PolicyRestrictionsClientCheckAtResourceGroupScopeOptions) (PolicyRestrictionsClientCheckAtResourceGroupScopeResponse, error)
CheckAtResourceGroupScope - Checks what restrictions Azure Policy will place on a resource within a resource group. Use this when the resource group the resource will be created in is already known. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-03-01
- resourceGroupName - The name of the resource group. The name is case insensitive.
- parameters - The check policy restrictions parameters.
- options - PolicyRestrictionsClientCheckAtResourceGroupScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtResourceGroupScope method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-03-01/examples/PolicyRestrictions_CheckAtResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyRestrictionsClient().CheckAtResourceGroupScope(ctx, "vmRg", armpolicyinsights.CheckRestrictionsRequest{ PendingFields: []*armpolicyinsights.PendingField{ { Field: to.Ptr("name"), Values: []*string{ to.Ptr("myVMName")}, }, { Field: to.Ptr("location"), Values: []*string{ to.Ptr("eastus"), to.Ptr("westus"), to.Ptr("westus2"), to.Ptr("westeurope")}, }, { Field: to.Ptr("tags"), }}, ResourceDetails: &armpolicyinsights.CheckRestrictionsResourceDetails{ APIVersion: to.Ptr("2019-12-01"), ResourceContent: map[string]any{ "type": "Microsoft.Compute/virtualMachines", "properties": map[string]any{ "priority": "Spot", }, }, }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.CheckRestrictionsResult = armpolicyinsights.CheckRestrictionsResult{ // ContentEvaluationResult: &armpolicyinsights.CheckRestrictionsResultContentEvaluationResult{ // PolicyEvaluations: []*armpolicyinsights.PolicyEvaluationResult{ // { // EvaluationDetails: &armpolicyinsights.PolicyEvaluationDetails{ // EvaluatedExpressions: []*armpolicyinsights.ExpressionEvaluationDetails{ // { // Path: to.Ptr("type"), // Expression: to.Ptr("type"), // ExpressionKind: to.Ptr("field"), // ExpressionValue: "microsoft.compute/virtualmachines", // Operator: to.Ptr("equals"), // Result: to.Ptr("True"), // TargetValue: "microsoft.compute/virtualmachines", // }}, // }, // EvaluationResult: to.Ptr("NonCompliant"), // PolicyInfo: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/2FF66C37"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/435CAE41"), // PolicyDefinitionReferenceID: to.Ptr("defref222"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/2162358E"), // }, // }}, // }, // FieldRestrictions: []*armpolicyinsights.FieldRestrictions{ // { // Field: to.Ptr("tags.newtag"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // DefaultValue: to.Ptr("defaultVal"), // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/57DAC8A0"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/1D0906C3"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/05D92080"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultRequired), // }}, // }, // { // Field: to.Ptr("tags.environment"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/7EB1508A"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/30BD79F6"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/735551F1"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultRequired), // Values: []*string{ // to.Ptr("Prod"), // to.Ptr("Int"), // to.Ptr("Test")}, // }}, // }, // { // Field: to.Ptr("location"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/1563EBD3"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/0711CCC1"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/1E17783A"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultDeny), // Values: []*string{ // to.Ptr("west europe")}, // }, // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/5382A69D"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/25C9F66B"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/392D107B"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultDeny), // Values: []*string{ // to.Ptr("eastus"), // to.Ptr("westus")}, // }}, // }}, // } }
Output:
func (*PolicyRestrictionsClient) CheckAtSubscriptionScope ¶
func (client *PolicyRestrictionsClient) CheckAtSubscriptionScope(ctx context.Context, parameters CheckRestrictionsRequest, options *PolicyRestrictionsClientCheckAtSubscriptionScopeOptions) (PolicyRestrictionsClientCheckAtSubscriptionScopeResponse, error)
CheckAtSubscriptionScope - Checks what restrictions Azure Policy will place on a resource within a subscription. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2022-03-01
- parameters - The check policy restrictions parameters.
- options - PolicyRestrictionsClientCheckAtSubscriptionScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtSubscriptionScope method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-03-01/examples/PolicyRestrictions_CheckAtSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyRestrictionsClient().CheckAtSubscriptionScope(ctx, armpolicyinsights.CheckRestrictionsRequest{ PendingFields: []*armpolicyinsights.PendingField{ { Field: to.Ptr("name"), Values: []*string{ to.Ptr("myVMName")}, }, { Field: to.Ptr("location"), Values: []*string{ to.Ptr("eastus"), to.Ptr("westus"), to.Ptr("westus2"), to.Ptr("westeurope")}, }, { Field: to.Ptr("tags"), }}, ResourceDetails: &armpolicyinsights.CheckRestrictionsResourceDetails{ APIVersion: to.Ptr("2019-12-01"), ResourceContent: map[string]any{ "type": "Microsoft.Compute/virtualMachines", "properties": map[string]any{ "priority": "Spot", }, }, }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.CheckRestrictionsResult = armpolicyinsights.CheckRestrictionsResult{ // ContentEvaluationResult: &armpolicyinsights.CheckRestrictionsResultContentEvaluationResult{ // PolicyEvaluations: []*armpolicyinsights.PolicyEvaluationResult{ // { // EvaluationDetails: &armpolicyinsights.PolicyEvaluationDetails{ // EvaluatedExpressions: []*armpolicyinsights.ExpressionEvaluationDetails{ // { // Path: to.Ptr("type"), // Expression: to.Ptr("type"), // ExpressionKind: to.Ptr("field"), // ExpressionValue: "microsoft.compute/virtualmachines", // Operator: to.Ptr("equals"), // Result: to.Ptr("True"), // TargetValue: "microsoft.compute/virtualmachines", // }}, // }, // EvaluationResult: to.Ptr("NonCompliant"), // PolicyInfo: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/2FF66C37"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/435CAE41"), // PolicyDefinitionReferenceID: to.Ptr("defref222"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/2162358E"), // }, // }}, // }, // FieldRestrictions: []*armpolicyinsights.FieldRestrictions{ // { // Field: to.Ptr("tags.newtag"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // DefaultValue: to.Ptr("defaultVal"), // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/57DAC8A0"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/1D0906C3"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/05D92080"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultRequired), // }}, // }, // { // Field: to.Ptr("tags.environment"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/7EB1508A"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/30BD79F6"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/735551F1"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultRequired), // Values: []*string{ // to.Ptr("Prod"), // to.Ptr("Int"), // to.Ptr("Test")}, // }}, // }, // { // Field: to.Ptr("location"), // Restrictions: []*armpolicyinsights.FieldRestriction{ // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/1563EBD3"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/0711CCC1"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/1E17783A"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultDeny), // Values: []*string{ // to.Ptr("west europe")}, // }, // { // Policy: &armpolicyinsights.PolicyReference{ // PolicyAssignmentID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyAssignments/5382A69D"), // PolicyDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policyDefinitions/25C9F66B"), // PolicyDefinitionReferenceID: to.Ptr("DefRef"), // PolicySetDefinitionID: to.Ptr("/subscriptions/d8db6de6-2b96-46af-b825-07aef2033c0b/providers/microsoft.authorization/policySetDefinitions/392D107B"), // }, // Result: to.Ptr(armpolicyinsights.FieldRestrictionResultDeny), // Values: []*string{ // to.Ptr("eastus"), // to.Ptr("westus")}, // }}, // }}, // } }
Output:
type PolicyRestrictionsClientCheckAtManagementGroupScopeOptions ¶ added in v0.3.0
type PolicyRestrictionsClientCheckAtManagementGroupScopeOptions struct { }
PolicyRestrictionsClientCheckAtManagementGroupScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtManagementGroupScope method.
type PolicyRestrictionsClientCheckAtManagementGroupScopeResponse ¶ added in v0.3.0
type PolicyRestrictionsClientCheckAtManagementGroupScopeResponse struct { // The result of a check policy restrictions evaluation on a resource. CheckRestrictionsResult }
PolicyRestrictionsClientCheckAtManagementGroupScopeResponse contains the response from method PolicyRestrictionsClient.CheckAtManagementGroupScope.
type PolicyRestrictionsClientCheckAtResourceGroupScopeOptions ¶
type PolicyRestrictionsClientCheckAtResourceGroupScopeOptions struct { }
PolicyRestrictionsClientCheckAtResourceGroupScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtResourceGroupScope method.
type PolicyRestrictionsClientCheckAtResourceGroupScopeResponse ¶
type PolicyRestrictionsClientCheckAtResourceGroupScopeResponse struct { // The result of a check policy restrictions evaluation on a resource. CheckRestrictionsResult }
PolicyRestrictionsClientCheckAtResourceGroupScopeResponse contains the response from method PolicyRestrictionsClient.CheckAtResourceGroupScope.
type PolicyRestrictionsClientCheckAtSubscriptionScopeOptions ¶
type PolicyRestrictionsClientCheckAtSubscriptionScopeOptions struct { }
PolicyRestrictionsClientCheckAtSubscriptionScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtSubscriptionScope method.
type PolicyRestrictionsClientCheckAtSubscriptionScopeResponse ¶
type PolicyRestrictionsClientCheckAtSubscriptionScopeResponse struct { // The result of a check policy restrictions evaluation on a resource. CheckRestrictionsResult }
PolicyRestrictionsClientCheckAtSubscriptionScopeResponse contains the response from method PolicyRestrictionsClient.CheckAtSubscriptionScope.
type PolicyState ¶
type PolicyState struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. AdditionalProperties map[string]any // Compliance state of the resource. ComplianceState *string // Components state compliance records populated only when URL contains $expand=components clause. Components []*ComponentStateDetails // Effective parameters for the policy assignment. EffectiveParameters *string // Flag which states whether the resource is compliant against the policy assignment it was evaluated against. This property // is deprecated; please use ComplianceState instead. IsCompliant *bool // Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. ManagementGroupIDs *string // OData context string; used by OData clients to resolve type information based on metadata. ODataContext *string // OData entity ID; always set to null since policy state records do not have an entity ID. ODataID *string // Policy assignment ID. PolicyAssignmentID *string // Policy assignment name. PolicyAssignmentName *string // Policy assignment owner. PolicyAssignmentOwner *string // Policy assignment parameters. PolicyAssignmentParameters *string // Policy assignment scope. PolicyAssignmentScope *string // Policy definition action, i.e. effect. PolicyDefinitionAction *string // Policy definition category. PolicyDefinitionCategory *string // Policy definition group names. PolicyDefinitionGroupNames []*string // Policy definition ID. PolicyDefinitionID *string // Policy definition name. PolicyDefinitionName *string // Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. PolicyDefinitionReferenceID *string // Policy evaluation details. PolicyEvaluationDetails *PolicyEvaluationDetails // Policy set definition category, if the policy assignment is for a policy set. PolicySetDefinitionCategory *string // Policy set definition ID, if the policy assignment is for a policy set. PolicySetDefinitionID *string // Policy set definition name, if the policy assignment is for a policy set. PolicySetDefinitionName *string // Policy set definition owner, if the policy assignment is for a policy set. PolicySetDefinitionOwner *string // Policy set definition parameters, if the policy assignment is for a policy set. PolicySetDefinitionParameters *string // Resource group name. ResourceGroup *string // Resource ID. ResourceID *string // Resource location. ResourceLocation *string // List of resource tags. ResourceTags *string // Resource type. ResourceType *string // Subscription ID. SubscriptionID *string // Timestamp for the policy state record. Timestamp *time.Time // READ-ONLY; Evaluated policy assignment version. PolicyAssignmentVersion *string // READ-ONLY; Evaluated policy definition version. PolicyDefinitionVersion *string // READ-ONLY; Evaluated policy set definition version. PolicySetDefinitionVersion *string }
PolicyState - Policy state record.
func (PolicyState) MarshalJSON ¶
func (p PolicyState) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyState.
func (*PolicyState) UnmarshalJSON ¶
func (p *PolicyState) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyState.
type PolicyStatesClient ¶
type PolicyStatesClient struct {
// contains filtered or unexported fields
}
PolicyStatesClient contains the methods for the PolicyStates group. Don't use this type directly, use NewPolicyStatesClient() instead.
func NewPolicyStatesClient ¶
func NewPolicyStatesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyStatesClient, error)
NewPolicyStatesClient creates a new instance of PolicyStatesClient with the specified values.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*PolicyStatesClient) BeginTriggerResourceGroupEvaluation ¶
func (client *PolicyStatesClient) BeginTriggerResourceGroupEvaluation(ctx context.Context, subscriptionID string, resourceGroupName string, options *PolicyStatesClientBeginTriggerResourceGroupEvaluationOptions) (*runtime.Poller[PolicyStatesClientTriggerResourceGroupEvaluationResponse], error)
BeginTriggerResourceGroupEvaluation - Triggers a policy evaluation scan for all the resources under the resource group. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- options - PolicyStatesClientBeginTriggerResourceGroupEvaluationOptions contains the optional parameters for the PolicyStatesClient.BeginTriggerResourceGroupEvaluation method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerResourceGroupEvaluation.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewPolicyStatesClient().BeginTriggerResourceGroupEvaluation(ctx, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } }
Output:
func (*PolicyStatesClient) BeginTriggerSubscriptionEvaluation ¶
func (client *PolicyStatesClient) BeginTriggerSubscriptionEvaluation(ctx context.Context, subscriptionID string, options *PolicyStatesClientBeginTriggerSubscriptionEvaluationOptions) (*runtime.Poller[PolicyStatesClientTriggerSubscriptionEvaluationResponse], error)
BeginTriggerSubscriptionEvaluation - Triggers a policy evaluation scan for all the resources under the subscription If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- subscriptionID - Microsoft Azure subscription ID.
- options - PolicyStatesClientBeginTriggerSubscriptionEvaluationOptions contains the optional parameters for the PolicyStatesClient.BeginTriggerSubscriptionEvaluation method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerSubscriptionEvaluation.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewPolicyStatesClient().BeginTriggerSubscriptionEvaluation(ctx, "fffedd8f-ffff-fffd-fffd-fffed2f84852", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForManagementGroupPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForManagementGroupPager(policyStatesResource PolicyStatesResource, managementGroupName string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForManagementGroupOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForManagementGroupResponse]
NewListQueryResultsForManagementGroupPager - Queries policy states for the resources under the management group.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- managementGroupName - Management group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForManagementGroupOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForManagementGroupPager method.
Example (QueryLatestAtManagementGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForManagementGroupPager(armpolicyinsights.PolicyStatesResourceLatest, "myManagementGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/1ef5d536aec743a0aa801c1a"), // PolicyAssignmentName: to.Ptr("1ef5d536aec743a0aa801c1a"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr("15521232277412542086"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // PolicySetDefinitionName: to.Ptr("335cefd2-ab16-430f-b364-974a170eb1d5"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/microsoft.insights/autoscalesettings/mytest1"), // ResourceLocation: to.Ptr("westus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.insights/autoscalesettings"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:41:47.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/186044306c044a1d8c0ff76c"), // PolicyAssignmentName: to.Ptr("186044306c044a1d8c0ff76c"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"centralus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/microsoft.insights/autoscalesettings/mytest1"), // ResourceLocation: to.Ptr("westus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.insights/autoscalesettings"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:41:47.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtManagementGroupScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForManagementGroupPager(armpolicyinsights.PolicyStatesResourceLatest, "myManagementGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/1ef5d536aec743a0aa801c1a"), // PolicyAssignmentName: to.Ptr("1ef5d536aec743a0aa801c1a"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr("15521232277412542086"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // PolicySetDefinitionName: to.Ptr("335cefd2-ab16-430f-b364-974a170eb1d5"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/microsoft.insights/autoscalesettings/mytest1"), // ResourceLocation: to.Ptr("westus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.insights/autoscalesettings"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:41:47.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("myManagementGroup,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/186044306c044a1d8c0ff76c"), // PolicyAssignmentName: to.Ptr("186044306c044a1d8c0ff76c"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"centralus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/microsoft.insights/autoscalesettings/mytest1"), // ResourceLocation: to.Ptr("westus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/microsoft.insights/autoscalesettings"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:41:47.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForPolicyDefinitionPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForPolicyDefinitionPager(policyStatesResource PolicyStatesResource, subscriptionID string, policyDefinitionName string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForPolicyDefinitionOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForPolicyDefinitionResponse]
NewListQueryResultsForPolicyDefinitionPager - Queries policy states for the subscription level policy definition.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- subscriptionID - Microsoft Azure subscription ID.
- policyDefinitionName - Policy definition name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForPolicyDefinitionOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForPolicyDefinitionPager method.
Example (QueryLatestAtSubscriptionLevelPolicyDefinitionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForPolicyDefinitionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "24813039-7534-408a-9842-eb99f45721b1", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/d9da7e80af6344ab9d342aa7"), // PolicyAssignmentName: to.Ptr("d9da7e80af6344ab9d342aa7"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"MyTag\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/services/myService"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications/services"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:50:27.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/d9da7e80af6344ab9d342aa7"), // PolicyAssignmentName: to.Ptr("d9da7e80af6344ab9d342aa7"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"MyTag\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/services/myService"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications/services"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:50:27.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtSubscriptionLevelPolicyDefinitionScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForPolicyDefinitionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "24813039-7534-408a-9842-eb99f45721b1", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/d9da7e80af6344ab9d342aa7"), // PolicyAssignmentName: to.Ptr("d9da7e80af6344ab9d342aa7"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"MyTag\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/services/myService"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications/services"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:50:27.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/d9da7e80af6344ab9d342aa7"), // PolicyAssignmentName: to.Ptr("d9da7e80af6344ab9d342aa7"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"MyTag\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/services/myService"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications/services"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:50:27.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForPolicySetDefinitionPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForPolicySetDefinitionPager(policyStatesResource PolicyStatesResource, subscriptionID string, policySetDefinitionName string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForPolicySetDefinitionOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForPolicySetDefinitionResponse]
NewListQueryResultsForPolicySetDefinitionPager - Queries policy states for the subscription level policy set definition.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- subscriptionID - Microsoft Azure subscription ID.
- policySetDefinitionName - Policy set definition name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForPolicySetDefinitionOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForPolicySetDefinitionPager method.
Example (QueryLatestAtSubscriptionLevelPolicySetDefinitionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForPolicySetDefinitionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "3e3807c1-65c9-49e0-a406-82d8ae3e338c", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/mySite"), // ResourceLocation: to.Ptr("centralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Web/sites"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:54:58.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("Audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/LocationAuditDefinition"), // PolicyDefinitionName: to.Ptr("LocationAuditDefinition"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/mySite"), // ResourceLocation: to.Ptr("centralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Web/sites"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:54:58.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtSubscriptionLevelPolicySetDefinitionScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForPolicySetDefinitionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "3e3807c1-65c9-49e0-a406-82d8ae3e338c", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/mySite"), // ResourceLocation: to.Ptr("centralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Web/sites"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:54:58.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("Audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/LocationAuditDefinition"), // PolicyDefinitionName: to.Ptr("LocationAuditDefinition"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/mySite"), // ResourceLocation: to.Ptr("centralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Web/sites"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:54:58.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, policyAssignmentName string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse]
NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager - Queries policy states for the resource group level policy assignment.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- policyAssignmentName - Policy assignment name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager method.
Example (QueryLatestAtResourceGroupLevelPolicyAssignmentScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", "myPolicyAssignment", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"EUS, WEU\"]}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionName: to.Ptr("4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Security/policies/mySecurityPolicy"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Security/policies"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:38:50.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"EUS, WEU\"]}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionName: to.Ptr("4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/test"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Authorization/policyAssignments"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:38:50.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtResourceGroupLevelPolicyAssignmentScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", "myPolicyAssignment", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"EUS, WEU\"]}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionName: to.Ptr("4a0425e4-97bf-4ad0-ab36-145b94083c60"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Security/policies/mySecurityPolicy"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Security/policies"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:38:50.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentName: to.Ptr("myPolicyAssignment"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"EUS, WEU\"]}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionName: to.Ptr("4a0425e4-97bf-4ad0-ab36-145b94083c60"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/test"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Authorization/policyAssignments"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:38:50.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForResourceGroupPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForResourceGroupPager(policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForResourceGroupOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForResourceGroupResponse]
NewListQueryResultsForResourceGroupPager - Queries policy states for the resources under the resource group.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForResourceGroupOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForResourceGroupPager method.
Example (QueryLatestAtResourceGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourceGroupPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/mysa1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Storage/storageAccounts"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T18:42:42.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e3682"), // PolicyDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e3682"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/mysa1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Storage/storageAccounts"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T18:42:42.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtResourceGroupScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourceGroupPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/mysa1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Storage/storageAccounts"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T18:42:42.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/3f3c4330183b4e218fe6fd29"), // PolicyAssignmentName: to.Ptr("3f3c4330183b4e218fe6fd29"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e3682"), // PolicyDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e3682"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // PolicySetDefinitionName: to.Ptr("3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/mysa1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Storage/storageAccounts"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T18:42:42.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForResourcePager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForResourcePager(policyStatesResource PolicyStatesResource, resourceID string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForResourceOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForResourceResponse]
NewListQueryResultsForResourcePager - Queries policy states for the resource.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- resourceID - Resource ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForResourceOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForResourcePager method.
Example (QueryAllPolicyStatesAtNestedResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryNestedResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/providers/Microsoft.PolicyInsights/policyStates/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyAssignments/186044306c044a1d8c0ff76c"), // PolicyAssignmentName: to.Ptr("186044306c044a1d8c0ff76c"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"centralus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyAssignments/186044306c044a1d8c0ff76c"), // PolicyAssignmentName: to.Ptr("186044306c044a1d8c0ff76c"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"centralus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApplication"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ServiceFabric/clusters/applications"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryAllPolicyStatesAtResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryAllPolicyStatesAtResourceScopeAndExpandPolicyEvaluationDetails) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceLatest, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: to.Ptr("PolicyEvaluationDetails"), }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicyEvaluationDetails: &armpolicyinsights.PolicyEvaluationDetails{ // EvaluatedExpressions: []*armpolicyinsights.ExpressionEvaluationDetails{ // { // Path: to.Ptr("type"), // Expression: to.Ptr("type"), // ExpressionValue: "Microsoft.ClassicCompute/domainNames", // Operator: to.Ptr("Equals"), // Result: to.Ptr("True"), // TargetValue: "Microsoft.ClassicCompute/domainNames", // }, // { // Path: to.Ptr("name"), // Expression: to.Ptr("name"), // ExpressionValue: "myDomainName", // Operator: to.Ptr("Equals"), // Result: to.Ptr("False"), // TargetValue: "someName", // }}, // }, // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test2"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("auditifnotexists"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/AuditIfNotExistsTest"), // PolicyDefinitionName: to.Ptr("AuditIfNotExists test"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicyEvaluationDetails: &armpolicyinsights.PolicyEvaluationDetails{ // EvaluatedExpressions: []*armpolicyinsights.ExpressionEvaluationDetails{ // { // Path: to.Ptr("tags"), // Expression: to.Ptr("tags"), // ExpressionValue: map[string]any{ // }, // Operator: to.Ptr("NotContainsKey"), // Result: to.Ptr("True"), // TargetValue: "global-opco", // }}, // IfNotExistsDetails: &armpolicyinsights.IfNotExistsEvaluationDetails{ // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // TotalResources: to.Ptr[int32](1), // }, // }, // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryAllPolicyStatesAtResourceScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourcegroups/myResourceGroup/providers/Microsoft.ClassicCompute/domainNames/myDomainName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.ClassicCompute/domainNames"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryAllPolicyStatesAtSubscriptionLevelNestedResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelNestedResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource/providers/Microsoft.PolicyInsights/policyStates/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyAssignments/186044306c044a1d8c0ff76c"), // PolicyAssignmentName: to.Ptr("186044306c044a1d8c0ff76c"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"centralus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType/someNestedResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyAssignments/186044306c044a1d8c0ff76c"), // PolicyAssignmentName: to.Ptr("186044306c044a1d8c0ff76c"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"allowedLocations\":{\"value\":[\"centralus\"]}}"), // PolicyAssignmentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/mymg/providers/Microsoft.Authorization/policyDefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionName: to.Ptr("022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResource/someNestedResourceType/someNestedResource"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType/someNestedResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryAllPolicyStatesAtSubscriptionLevelResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceDefault, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName/providers/Microsoft.PolicyInsights/policyStates/$metadata#default/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/test"), // PolicyAssignmentName: to.Ptr("test"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"tagName\":{\"value\":\"no\"},\"tagValue\":{\"value\":\"no\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyDefinitions/Audit a tag and it's value"), // PolicyDefinitionName: to.Ptr("Audit a tag and it's value"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // ResourceGroup: to.Ptr(""), // ResourceID: to.Ptr("/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.SomeNamespace/someResourceType/someResourceName"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.SomeNamespace/someResourceType"), // SubscriptionID: to.Ptr("fff10b27-fff3-fff5-fff8-fffbe01e86a5"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T16:04:31.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryComponentPolicyComplianceStateAtResourceScopeFilteredByGivenAssignment) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandComponents.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceLatest, "subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", &armpolicyinsights.QueryOptions{Top: nil, Filter: to.Ptr("policyAssignmentId eq '/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: to.Ptr("components($filter=ComplianceState eq 'NonCompliant' or ComplianceState eq 'Compliant')"), }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // Components: []*armpolicyinsights.ComponentStateDetails{ // { // Name: to.Ptr("cert-RSA-cert-3"), // Type: to.Ptr("Certificate"), // ComplianceState: to.Ptr("NonCompliant"), // ID: to.Ptr("cert-RSA-cert-3"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:23.036Z"); return t}()), // }, // { // Name: to.Ptr("cert-RSA-cert-2"), // Type: to.Ptr("Certificate"), // ComplianceState: to.Ptr("NonCompliant"), // ID: to.Ptr("cert-RSA-cert-2"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:22.768Z"); return t}()), // }, // { // Name: to.Ptr("cert-rsa-cert-expires-2months"), // Type: to.Ptr("Certificate"), // ComplianceState: to.Ptr("NonCompliant"), // ID: to.Ptr("cert-rsa-cert-expires-2months"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:22.684Z"); return t}()), // }, // { // Name: to.Ptr("cert-RSA-cert-1"), // Type: to.Ptr("Certificate"), // ComplianceState: to.Ptr("Compliant"), // ID: to.Ptr("cert-RSA-cert-1"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:22.650Z"); return t}()), // }, // { // Name: to.Ptr("cert-rsa-cert-expires-1month"), // Type: to.Ptr("Certificate"), // ComplianceState: to.Ptr("NonCompliant"), // ID: to.Ptr("cert-rsa-cert-expires-1month"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T17:45:22.552Z"); return t}()), // }}, // EffectiveParameters: to.Ptr(""), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("PolicyUIMG,AzGovTest5,72f988bf-86f1-41af-91ab-2d7cd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8"), // PolicyAssignmentName: to.Ptr("560050f83dbb4a24974323f8"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr(""), // PolicyAssignmentScope: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policydefinitions/ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionName: to.Ptr("ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionCategory: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // PolicySetDefinitionOwner: to.Ptr(""), // PolicySetDefinitionParameters: to.Ptr(""), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName"), // ResourceLocation: to.Ptr("westcentralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("Microsoft.KeyVault/vaults"), // SubscriptionID: to.Ptr("e78961ba-36fe-4739-9212-e3031b4c8db7"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T19:42:08.325Z"); return t}()), // }}, // } } }
Output:
Example (QueryComponentPolicyComplianceStateCountGroupedByStateTypeAtResourceScopeFilteredByGivenAssignment) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandComponentsGroupByWithAggregate.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForResourcePager(armpolicyinsights.PolicyStatesResourceLatest, "subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", &armpolicyinsights.QueryOptions{Top: nil, Filter: to.Ptr("policyAssignmentId eq '/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: to.Ptr("components($filter=ComplianceState eq 'NonCompliant' or ComplianceState eq 'Compliant';$apply=groupby((complianceState),aggregate($count as count)))"), }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // Components: []*armpolicyinsights.ComponentStateDetails{ // { // AdditionalProperties: map[string]any{ // "count": float64(5), // }, // ComplianceState: to.Ptr("NonCompliant"), // }, // { // AdditionalProperties: map[string]any{ // "count": float64(14), // }, // ComplianceState: to.Ptr("Compliant"), // }}, // EffectiveParameters: to.Ptr(""), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("PolicyUIMG,AzGovTest5,72f988bf-86f1-41af-91ab-2d7cd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policyassignments/560050f83dbb4a24974323f8"), // PolicyAssignmentName: to.Ptr("560050f83dbb4a24974323f8"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr(""), // PolicyAssignmentScope: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/providers/microsoft.authorization/policydefinitions/ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionName: to.Ptr("ab108bc4-32df-4677-8b38-fa8b2905df59"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionCategory: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // PolicySetDefinitionName: to.Ptr(""), // PolicySetDefinitionOwner: to.Ptr(""), // PolicySetDefinitionParameters: to.Ptr(""), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourcegroups/myResourceGroup/providers/microsoft.keyvault/vaults/myKVName"), // ResourceLocation: to.Ptr("westcentralus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("Microsoft.KeyVault/vaults"), // SubscriptionID: to.Ptr("e78961ba-36fe-4739-9212-e3031b4c8db7"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-21T19:42:08.325Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(policyStatesResource PolicyStatesResource, subscriptionID string, policyAssignmentName string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse]
NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager - Queries policy states for the subscription level policy assignment.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- subscriptionID - Microsoft Azure subscription ID.
- policyAssignmentName - Policy assignment name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager method.
Example (QueryLatestAtSubscriptionLevelPolicyAssignmentScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "ec8f9645-8ecb-4abb-9c0b-5292f19d4003", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"test\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionName: to.Ptr("c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("2124621540977569058"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/my-ip-1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:45:19.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"test\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("14799174781370023846"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/my-ip-1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:45:19.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtSubscriptionLevelPolicyAssignmentScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "ec8f9645-8ecb-4abb-9c0b-5292f19d4003", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"test\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionName: to.Ptr("c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("2124621540977569058"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/my-ip-1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:45:19.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("Compliant"), // IsCompliant: to.Ptr(true), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentName: to.Ptr("ec8f9645-8ecb-4abb-9c0b-5292f19d4003"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{\"TAGNAME_1\":{\"value\":\"test\"}}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionName: to.Ptr("24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("14799174781370023846"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // PolicySetDefinitionName: to.Ptr("12b58873-e0f8-4b95-936c-86cbe7c9d697"), // ResourceGroup: to.Ptr("myResourceGroup"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/my-ip-1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-13T00:45:19.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) NewListQueryResultsForSubscriptionPager ¶ added in v0.4.0
func (client *PolicyStatesClient) NewListQueryResultsForSubscriptionPager(policyStatesResource PolicyStatesResource, subscriptionID string, queryOptions *QueryOptions, options *PolicyStatesClientListQueryResultsForSubscriptionOptions) *runtime.Pager[PolicyStatesClientListQueryResultsForSubscriptionResponse]
NewListQueryResultsForSubscriptionPager - Queries policy states for the resources under the subscription.
Generated from API version 2019-10-01
- policyStatesResource - The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s).
- subscriptionID - Microsoft Azure subscription ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientListQueryResultsForSubscriptionOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForSubscriptionPager method.
Example (FilterAndAggregateOnly) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndAggregateOnly.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: nil, Filter: to.Ptr("PolicyDefinitionAction eq 'deny'"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("aggregate($count as NumDenyStates)"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.PolicyState{ // { // AdditionalProperties: map[string]any{ // "NumDenyStates": float64(6), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // }}, // } } }
Output:
Example (FilterAndGroupWithAggregate) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndGroupByWithAggregate.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: to.Ptr("IsCompliant eq false and (PolicyDefinitionAction eq 'audit' or PolicyDefinitionAction eq 'deny')"), OrderBy: to.Ptr("NumAuditDenyNonComplianceRecords desc"), Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("groupby((PolicyAssignmentId, PolicyDefinitionId, PolicyDefinitionAction, ResourceId), aggregate($count as NumAuditDenyNonComplianceRecords))"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // AdditionalProperties: map[string]any{ // "NumAuditDenyNonComplianceRecords": float64(10), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myrg/providers/microsoft.classiccompute/domainnames/myDomainName"), // }, // { // AdditionalProperties: map[string]any{ // "NumAuditDenyNonComplianceRecords": float64(10), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1"), // PolicyDefinitionAction: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myrg/providers/microsoft.classiccompute/domainnames/myDomainName"), // }}, // } } }
Output:
Example (FilterAndGroupWithoutAggregate) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndGroupByWithoutAggregate.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: to.Ptr("IsCompliant eq false and (PolicyDefinitionAction ne 'audit' and PolicyDefinitionAction ne 'append')"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00.000Z"); return t }()), To: nil, Apply: to.Ptr("groupby((PolicyAssignmentId, PolicyDefinitionId, PolicyDefinitionAction, ResourceId))"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/enable monitoring in azure security center"), // PolicyDefinitionAction: to.Ptr("auditifnotexists"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myrg/providers/microsoft.network/virtualnetworks/vnet"), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/89b27f38-e9e4-4468-ab81-801c84b8c017"), // PolicyDefinitionAction: to.Ptr("auditifnotexists"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.authorization/policydefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myrg/providers/microsoft.network/virtualnetworks/vnet"), // }}, // } } }
Output:
Example (FilterAndMultipleGroups) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndMultipleGroups.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](10), Filter: to.Ptr("IsCompliant eq false"), OrderBy: to.Ptr("NumNonCompliantResources desc"), Select: nil, From: nil, To: nil, Apply: to.Ptr("groupby((PolicyAssignmentId, PolicySetDefinitionId, PolicyDefinitionId, PolicyDefinitionReferenceId, ResourceId))/groupby((PolicyAssignmentId, PolicySetDefinitionId, PolicyDefinitionId, PolicyDefinitionReferenceId), aggregate($count as NumNonCompliantResources))"), SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](10), // Value: []*armpolicyinsights.PolicyState{ // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(557), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("14799174781370023846"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(557), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("1679708035638239273"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(557), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("14799174781370023846"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(557), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("1679708035638239273"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(557), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(557), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/dcda79d769674aea8bfcaa49"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(552), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(544), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("8935913113203900114"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad"), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(526), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/8174043a1e2849179635b874"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policydefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr(""), // PolicySetDefinitionID: to.Ptr(""), // }, // { // AdditionalProperties: map[string]any{ // "NumNonCompliantResources": float64(509), // }, // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("2124621540977569058"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // }}, // } } }
Output:
Example (QueryLatestAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/Enable Monitoring in Azure Security Center"), // PolicyAssignmentName: to.Ptr("Enable Monitoring in Azure Security Center"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("AuditIfNotExists"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionName: to.Ptr("9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/Microsoft.Network/publicIPAddresses/mypubip1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:48:05.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/9ac09b0657d942e5ad4041a6"), // PolicyAssignmentName: to.Ptr("9ac09b0657d942e5ad4041a6"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyAssignmentVersion: to.Ptr("1.0.0"), // PolicyDefinitionAction: to.Ptr("AuditIfNotExists"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionName: to.Ptr("9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionVersion: to.Ptr("1.0.0-preview"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionVersion: to.Ptr("2.0.1"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/Microsoft.Network/publicIPAddresses/mypubip1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:48:05.000Z"); return t}()), // }}, // } } }
Output:
Example (QueryLatestAtSubscriptionScopeWithNextLink) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionScopeNextLink.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: to.Ptr("WpmWfBSvPhkAK6QD"), Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/Enable Monitoring in Azure Security Center"), // PolicyAssignmentName: to.Ptr("Enable Monitoring in Azure Security Center"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("AuditIfNotExists"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionName: to.Ptr("9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/Microsoft.Network/publicIPAddresses/mypubip1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:48:05.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // ComplianceState: to.Ptr("NonCompliant"), // IsCompliant: to.Ptr(false), // ManagementGroupIDs: to.Ptr("mymg,fff988bf-fff1-ffff-fffb-fffcd011db47"), // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyAssignments/9ac09b0657d942e5ad4041a6"), // PolicyAssignmentName: to.Ptr("9ac09b0657d942e5ad4041a6"), // PolicyAssignmentOwner: to.Ptr("tbd"), // PolicyAssignmentParameters: to.Ptr("{}"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852"), // PolicyDefinitionAction: to.Ptr("AuditIfNotExists"), // PolicyDefinitionCategory: to.Ptr("tbd"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicyDefinitionName: to.Ptr("9daedab3-fb2d-461e-b861-71790eead4f6"), // PolicySetDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // PolicySetDefinitionName: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/Microsoft.Network/publicIPAddresses/mypubip1"), // ResourceLocation: to.Ptr("eastus"), // ResourceTags: to.Ptr("tbd"), // ResourceType: to.Ptr("/Microsoft.Network/publicIPAddresses"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-09T17:48:05.000Z"); return t}()), // }}, // } } }
Output:
Example (TimeRangeSortSelectAndLimit) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TimeRangeSortSelectTop.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyStatesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyStatesResourceLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: nil, OrderBy: to.Ptr("Timestamp desc, PolicyAssignmentId asc, SubscriptionId asc, ResourceGroup asc, ResourceId"), Select: to.Ptr("Timestamp, PolicyAssignmentId, PolicyDefinitionId, SubscriptionId, ResourceGroup, ResourceId, policyDefinitionGroupNames"), From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00.000Z"); return t }()), To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00.000Z"); return t }()), Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyStatesQueryResults = armpolicyinsights.PolicyStatesQueryResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest"), // ODataCount: to.Ptr[int32](2), // Value: []*armpolicyinsights.PolicyState{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/8cb1e007-947f-423a-ad0c-7ab7dc7d0255/providers/Microsoft.Authorization/policyAssignments/1654a0254ab34920a60f94eb"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("myGroup")}, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), // ResourceGroup: to.Ptr("myrg1"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg1/providers/Microsoft.Storage/storageAccounts/mysa1"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T17:58:00.000Z"); return t}()), // }, // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#latest/$entity"), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/8cb1e007-947f-423a-ad0c-7ab7dc7d0255/providers/Microsoft.Authorization/policyAssignments/1654a0254ab34920a60f94eb"), // PolicyDefinitionGroupNames: []*string{ // }, // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), // ResourceGroup: to.Ptr("myrg2"), // ResourceID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myrg2/providers/Microsoft.Storage/storageAccounts/mysa2"), // SubscriptionID: to.Ptr("fffedd8f-ffff-fffd-fffd-fffed2f84852"), // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T17:58:00.000Z"); return t}()), // }}, // } } }
Output:
func (*PolicyStatesClient) SummarizeForManagementGroup ¶
func (client *PolicyStatesClient) SummarizeForManagementGroup(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, managementGroupName string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForManagementGroupOptions) (PolicyStatesClientSummarizeForManagementGroupResponse, error)
SummarizeForManagementGroup - Summarizes policy states for the resources under the management group. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- managementGroupName - Management group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForManagementGroupOptions contains the optional parameters for the PolicyStatesClient.SummarizeForManagementGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeManagementGroupScope.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForManagementGroup(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "myManagementGroup", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](0), Filter: to.Ptr("PolicyDefinitionAction eq 'deny' or PolicyDefinitionAction eq 'audit'"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00.000Z"); return t }()), To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00.000Z"); return t }()), Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // }, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](68), // NonCompliantResources: to.Ptr[int32](15410), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](68), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](14), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-05 18:00:00Z&$to=2019-10-06 18:00:00Z&$filter=(PolicyDefinitionAction eq 'deny' or PolicyDefinitionAction eq 'audit') and IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](1400), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](15410), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForPolicyDefinition ¶
func (client *PolicyStatesClient) SummarizeForPolicyDefinition(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, subscriptionID string, policyDefinitionName string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForPolicyDefinitionOptions) (PolicyStatesClientSummarizeForPolicyDefinitionResponse, error)
SummarizeForPolicyDefinition - Summarizes policy states for the subscription level policy definition. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- subscriptionID - Microsoft Azure subscription ID.
- policyDefinitionName - Policy definition name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForPolicyDefinitionOptions contains the optional parameters for the PolicyStatesClient.SummarizeForPolicyDefinition method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyDefinitionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForPolicyDefinition(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "24813039-7534-408a-9842-eb99f45721b1", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](558), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](558), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](7), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](558), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](558), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](558), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("2481303924813039"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](553), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](553), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](553), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](553), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](553), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](553), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/ddd8ef92e3714a5ea3d208c1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](531), // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531'"), // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](4), // NonCompliantResources: to.Ptr[int32](561), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policyDefinitions/24813039-7534-408a-9842-eb99f45721b1/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:07:10Z&$to=2019-10-13 20:07:10Z&$filter=IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](561), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForPolicySetDefinition ¶
func (client *PolicyStatesClient) SummarizeForPolicySetDefinition(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, subscriptionID string, policySetDefinitionName string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForPolicySetDefinitionOptions) (PolicyStatesClientSummarizeForPolicySetDefinitionResponse, error)
SummarizeForPolicySetDefinition - Summarizes policy states for the subscription level policy set definition. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- subscriptionID - Microsoft Azure subscription ID.
- policySetDefinitionName - Policy set definition name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForPolicySetDefinitionOptions contains the optional parameters for the PolicyStatesClient.SummarizeForPolicySetDefinition method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicySetDefinitionScope.json
package main import ( "context" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForPolicySetDefinition(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "3e3807c1-65c9-49e0-a406-82d8ae3e338c", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyDefinitionAction eq 'deny'"), OrderBy: nil, Select: nil, From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00.000Z"); return t }()), To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00.000Z"); return t }()), Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // }, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](0), // NonCompliantResources: to.Ptr[int32](0), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.Authorization/policySetDefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-05 18:00:00Z&$to=2019-10-06 18:00:00Z&$filter=(PolicyDefinitionAction eq 'deny') and IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForResource ¶
func (client *PolicyStatesClient) SummarizeForResource(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, resourceID string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForResourceOptions) (PolicyStatesClientSummarizeForResourceResponse, error)
SummarizeForResource - Summarizes policy states for the resource. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- resourceID - Resource ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForResourceOptions contains the optional parameters for the PolicyStatesClient.SummarizeForResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForResource(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](2), Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/8174043a1e2849179635b874"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policydefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](1), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:59:17Z&$to=2019-10-13 19:59:17Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/8174043a1e2849179635b874' and PolicyDefinitionId eq '/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policydefinitions/72c0c41a-c752-4bc0-9c61-0d6adc567066'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](7), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/8174043a1e2849179635b874'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](1), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:59:17Z&$to=2019-10-13 19:59:17Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/8174043a1e2849179635b874'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](1), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:59:17Z&$to=2019-10-13 19:59:17Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and PolicyDefinitionId eq '/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](100), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](1), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:59:17Z&$to=2019-10-13 19:59:17Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/mymg/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](14), // NonCompliantResources: to.Ptr[int32](1), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](2), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/my-vault/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:59:17Z&$to=2019-10-13 19:59:17Z&$filter=IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForResourceGroup ¶
func (client *PolicyStatesClient) SummarizeForResourceGroup(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, subscriptionID string, resourceGroupName string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForResourceGroupOptions) (PolicyStatesClientSummarizeForResourceGroupResponse, error)
SummarizeForResourceGroup - Summarizes policy states for the resources under the resource group. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForResourceGroupOptions contains the optional parameters for the PolicyStatesClient.SummarizeForResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForResourceGroup(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/186044306c044a1d8c0ff76c"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](100), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:55:09Z&$to=2019-10-13 19:55:09Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/186044306c044a1d8c0ff76c' and PolicyDefinitionId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](100), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](100), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/186044306c044a1d8c0ff76c' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](100), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](55), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](2), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:55:09Z&$to=2019-10-13 19:55:09Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/186044306c044a1d8c0ff76c'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](55), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](55), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:55:09Z&$to=2019-10-13 19:55:09Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and PolicyDefinitionId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](55), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](55), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](55), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:55:09Z&$to=2019-10-13 19:55:09Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](55), // }}, // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](20), // NonCompliantResources: to.Ptr[int32](55), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](2), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:55:09Z&$to=2019-10-13 19:55:09Z&$filter=IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](55), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignment ¶
func (client *PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignment(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, subscriptionID string, resourceGroupName string, policyAssignmentName string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentOptions) (PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResponse, error)
SummarizeForResourceGroupLevelPolicyAssignment - Summarizes policy states for the resource group level policy assignment. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- subscriptionID - Microsoft Azure subscription ID.
- resourceGroupName - Resource group name.
- policyAssignmentName - Policy assignment name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupLevelPolicyAssignmentScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForResourceGroupLevelPolicyAssignment(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "myResourceGroup", "b7a1ca2596524e3ab19597f2", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/b7a1ca2596524e3ab19597f2/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/b7a1ca2596524e3ab19597f2/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b7a1ca2596524e3ab19597f2"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/4a0425e4-97bf-4ad0-ab36-145b94083c60"), // PolicyDefinitionReferenceID: to.Ptr("2134906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](7), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/b7a1ca2596524e3ab19597f2/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-22 23:54:22Z&$to=2019-10-23 23:54:22Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b7a1ca2596524e3ab19597f2' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/4a0425e4-97bf-4ad0-ab36-145b94083c60'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](7), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/b7a1ca2596524e3ab19597f2' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](7), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](7), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/b7a1ca2596524e3ab19597f2/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-22 23:54:22Z&$to=2019-10-23 23:54:22Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b7a1ca2596524e3ab19597f2'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](7), // }}, // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](7), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/b7a1ca2596524e3ab19597f2/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-22 23:54:22Z&$to=2019-10-23 23:54:22Z&$filter=IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](7), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForSubscription ¶
func (client *PolicyStatesClient) SummarizeForSubscription(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, subscriptionID string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForSubscriptionOptions) (PolicyStatesClientSummarizeForSubscriptionResponse, error)
SummarizeForSubscription - Summarizes policy states for the resources under the subscription. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- subscriptionID - Microsoft Azure subscription ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForSubscriptionOptions contains the optional parameters for the PolicyStatesClient.SummarizeForSubscription method.
Example (SummarizeAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForSubscription(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](5), Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("1b249ab8b4741b249ab8b474"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/d9da7e80af6344ab9d342aa7'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/dcda79d769674aea8bfcaa49"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/dcda79d769674aea8bfcaa49' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/dcda79d769674aea8bfcaa49'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr(""), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/dcda79d769674aea8bfcaa49'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d"), // PolicyDefinitionReferenceID: to.Ptr("2134906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and PolicyDefinitionId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policydefinitions/022d9357-5a90-46f7-9554-21d30ce4c32d'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/providers/microsoft.management/managementgroups/myManagementGroup/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }, // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("5434906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](552), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](552), // }}, // }, // }, // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/locationauditdefinition"), // PolicyDefinitionReferenceID: to.Ptr("8724906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](29), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/locationauditdefinition'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](29), // }}, // }, // }, // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e3682"), // PolicyDefinitionReferenceID: to.Ptr("7254906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](2), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e3682'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](2), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](3), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](552), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e338c"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](3), // NonCompliantResources: to.Ptr[int32](552), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](3), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/3f3c4330183b4e218fe6fd29'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](552), // }}, // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](40), // NonCompliantResources: to.Ptr[int32](619), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter=IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](619), // }}, // }, // }}, // } }
Output:
Example (SummarizeAtSubscriptionScopeForAPolicyDefinitionGroup) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScopeForPolicyGroup.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForSubscription(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("'group1' IN PolicyDefinitionGroupNames"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/ab379b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("1595906828137356523"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/ab379b49-a579-4045-984e-1b249ab8b474'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }, // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("2134906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](34), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](510), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](34), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](2), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad' and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](14), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](557), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/a03db67e-a286-43c3-9098-b2da83d361ad"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](2), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/e46af646ebdb461dba708e01'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](17), // }}, // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](557), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](17), // }}, // }, // }}, // } }
Output:
func (*PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignment ¶
func (client *PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignment(ctx context.Context, policyStatesSummaryResource PolicyStatesSummaryResourceType, subscriptionID string, policyAssignmentName string, queryOptions *QueryOptions, options *PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentOptions) (PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResponse, error)
SummarizeForSubscriptionLevelPolicyAssignment - Summarizes policy states for the subscription level policy assignment. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2019-10-01
- policyStatesSummaryResource - The virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value.
- subscriptionID - Microsoft Azure subscription ID.
- policyAssignmentName - Policy assignment name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyAssignmentScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewPolicyStatesClient().SummarizeForSubscriptionLevelPolicyAssignment(ctx, armpolicyinsights.PolicyStatesSummaryResourceTypeLatest, "fffedd8f-ffff-fffd-fffd-fffed2f84852", "ec8f9645-8ecb-4abb-9c0b-5292f19d4003", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.SummarizeResults = armpolicyinsights.SummarizeResults{ // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary"), // ODataCount: to.Ptr[int32](1), // Value: []*armpolicyinsights.Summary{ // { // ODataContext: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity"), // PolicyAssignments: []*armpolicyinsights.PolicyAssignmentSummary{ // { // PolicyAssignmentID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531"), // PolicyDefinitions: []*armpolicyinsights.PolicyDefinitionSummary{ // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474"), // PolicyDefinitionReferenceID: to.Ptr("2134906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:09:24Z&$to=2019-10-13 20:09:24Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/c8b79b49-a579-4045-984e-1b249ab8b474'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }, // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1"), // PolicyDefinitionReferenceID: to.Ptr("3424906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:09:24Z&$to=2019-10-13 20:09:24Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/24813039-7534-408a-9842-eb99f45721b1'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }, // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/locationauditdefinition"), // PolicyDefinitionReferenceID: to.Ptr("7943906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](220), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:09:24Z&$to=2019-10-13 20:09:24Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/locationauditdefinition'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](220), // }}, // }, // }, // { // Effect: to.Ptr("audit"), // PolicyDefinitionGroupNames: []*string{ // to.Ptr("group1")}, // PolicyDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e3682"), // PolicyDefinitionReferenceID: to.Ptr("1234906828137356512"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](54), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:09:24Z&$to=2019-10-13 20:09:24Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531' and PolicyDefinitionId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policydefinitions/3e3807c1-65c9-49e0-a406-82d8ae3e3682'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](54), // }}, // }, // }}, // PolicyGroups: []*armpolicyinsights.PolicyGroupSummary{ // { // PolicyGroupName: to.Ptr("group1"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantResources: to.Ptr[int32](100), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 19:48:53Z&$to=2019-10-13 19:48:53Z&$filter='group1' IN PolicyDefinitionGroupNames and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/1ef5d536aec743a0aa801c1a' and PolicySetDefinitiontId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/335cefd2-ab16-430f-b364-974a170eb1d5' and 'group1' IN PolicyDefinitionGroupNames"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](100), // }}, // }, // }}, // PolicySetDefinitionID: to.Ptr("/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policysetdefinitions/12b58873-e0f8-4b95-936c-86cbe7c9d697"), // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](4), // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](4), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:09:24Z&$to=2019-10-13 20:09:24Z&$filter=IsCompliant eq false and PolicyAssignmentId eq '/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531'"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }}, // Results: &armpolicyinsights.SummaryResults{ // NonCompliantPolicies: to.Ptr[int32](1), // NonCompliantResources: to.Ptr[int32](531), // PolicyDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // PolicyGroupDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](1), // }}, // QueryResultsURI: to.Ptr("https://management.azure.com/subscriptions/fffedd8f-ffff-fffd-fffd-fffed2f84852/providers/microsoft.authorization/policyassignments/f4cc58b7db524a9799381531/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-12 20:09:24Z&$to=2019-10-13 20:09:24Z&$filter=IsCompliant eq false"), // ResourceDetails: []*armpolicyinsights.ComplianceDetail{ // { // ComplianceState: to.Ptr("compliant"), // Count: to.Ptr[int32](140), // }, // { // ComplianceState: to.Ptr("noncompliant"), // Count: to.Ptr[int32](531), // }}, // }, // }}, // } }
Output:
type PolicyStatesClientBeginTriggerResourceGroupEvaluationOptions ¶
type PolicyStatesClientBeginTriggerResourceGroupEvaluationOptions struct { // Resumes the LRO from the provided token. ResumeToken string }
PolicyStatesClientBeginTriggerResourceGroupEvaluationOptions contains the optional parameters for the PolicyStatesClient.BeginTriggerResourceGroupEvaluation method.
type PolicyStatesClientBeginTriggerSubscriptionEvaluationOptions ¶
type PolicyStatesClientBeginTriggerSubscriptionEvaluationOptions struct { // Resumes the LRO from the provided token. ResumeToken string }
PolicyStatesClientBeginTriggerSubscriptionEvaluationOptions contains the optional parameters for the PolicyStatesClient.BeginTriggerSubscriptionEvaluation method.
type PolicyStatesClientListQueryResultsForManagementGroupOptions ¶
type PolicyStatesClientListQueryResultsForManagementGroupOptions struct { }
PolicyStatesClientListQueryResultsForManagementGroupOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForManagementGroupPager method.
type PolicyStatesClientListQueryResultsForManagementGroupResponse ¶
type PolicyStatesClientListQueryResultsForManagementGroupResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForManagementGroupResponse contains the response from method PolicyStatesClient.NewListQueryResultsForManagementGroupPager.
type PolicyStatesClientListQueryResultsForPolicyDefinitionOptions ¶
type PolicyStatesClientListQueryResultsForPolicyDefinitionOptions struct { }
PolicyStatesClientListQueryResultsForPolicyDefinitionOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForPolicyDefinitionPager method.
type PolicyStatesClientListQueryResultsForPolicyDefinitionResponse ¶
type PolicyStatesClientListQueryResultsForPolicyDefinitionResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForPolicyDefinitionResponse contains the response from method PolicyStatesClient.NewListQueryResultsForPolicyDefinitionPager.
type PolicyStatesClientListQueryResultsForPolicySetDefinitionOptions ¶
type PolicyStatesClientListQueryResultsForPolicySetDefinitionOptions struct { }
PolicyStatesClientListQueryResultsForPolicySetDefinitionOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForPolicySetDefinitionPager method.
type PolicyStatesClientListQueryResultsForPolicySetDefinitionResponse ¶
type PolicyStatesClientListQueryResultsForPolicySetDefinitionResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForPolicySetDefinitionResponse contains the response from method PolicyStatesClient.NewListQueryResultsForPolicySetDefinitionPager.
type PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions ¶
type PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions struct { }
PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager method.
type PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse ¶
type PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse contains the response from method PolicyStatesClient.NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager.
type PolicyStatesClientListQueryResultsForResourceGroupOptions ¶
type PolicyStatesClientListQueryResultsForResourceGroupOptions struct { }
PolicyStatesClientListQueryResultsForResourceGroupOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForResourceGroupPager method.
type PolicyStatesClientListQueryResultsForResourceGroupResponse ¶
type PolicyStatesClientListQueryResultsForResourceGroupResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForResourceGroupResponse contains the response from method PolicyStatesClient.NewListQueryResultsForResourceGroupPager.
type PolicyStatesClientListQueryResultsForResourceOptions ¶
type PolicyStatesClientListQueryResultsForResourceOptions struct { }
PolicyStatesClientListQueryResultsForResourceOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForResourcePager method.
type PolicyStatesClientListQueryResultsForResourceResponse ¶
type PolicyStatesClientListQueryResultsForResourceResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForResourceResponse contains the response from method PolicyStatesClient.NewListQueryResultsForResourcePager.
type PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions ¶
type PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions struct { }
PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager method.
type PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse ¶
type PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse contains the response from method PolicyStatesClient.NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager.
type PolicyStatesClientListQueryResultsForSubscriptionOptions ¶
type PolicyStatesClientListQueryResultsForSubscriptionOptions struct { }
PolicyStatesClientListQueryResultsForSubscriptionOptions contains the optional parameters for the PolicyStatesClient.NewListQueryResultsForSubscriptionPager method.
type PolicyStatesClientListQueryResultsForSubscriptionResponse ¶
type PolicyStatesClientListQueryResultsForSubscriptionResponse struct { // Query results. PolicyStatesQueryResults }
PolicyStatesClientListQueryResultsForSubscriptionResponse contains the response from method PolicyStatesClient.NewListQueryResultsForSubscriptionPager.
type PolicyStatesClientSummarizeForManagementGroupOptions ¶
type PolicyStatesClientSummarizeForManagementGroupOptions struct { }
PolicyStatesClientSummarizeForManagementGroupOptions contains the optional parameters for the PolicyStatesClient.SummarizeForManagementGroup method.
type PolicyStatesClientSummarizeForManagementGroupResponse ¶
type PolicyStatesClientSummarizeForManagementGroupResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForManagementGroupResponse contains the response from method PolicyStatesClient.SummarizeForManagementGroup.
type PolicyStatesClientSummarizeForPolicyDefinitionOptions ¶
type PolicyStatesClientSummarizeForPolicyDefinitionOptions struct { }
PolicyStatesClientSummarizeForPolicyDefinitionOptions contains the optional parameters for the PolicyStatesClient.SummarizeForPolicyDefinition method.
type PolicyStatesClientSummarizeForPolicyDefinitionResponse ¶
type PolicyStatesClientSummarizeForPolicyDefinitionResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForPolicyDefinitionResponse contains the response from method PolicyStatesClient.SummarizeForPolicyDefinition.
type PolicyStatesClientSummarizeForPolicySetDefinitionOptions ¶
type PolicyStatesClientSummarizeForPolicySetDefinitionOptions struct { }
PolicyStatesClientSummarizeForPolicySetDefinitionOptions contains the optional parameters for the PolicyStatesClient.SummarizeForPolicySetDefinition method.
type PolicyStatesClientSummarizeForPolicySetDefinitionResponse ¶
type PolicyStatesClientSummarizeForPolicySetDefinitionResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForPolicySetDefinitionResponse contains the response from method PolicyStatesClient.SummarizeForPolicySetDefinition.
type PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentOptions ¶
type PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentOptions struct { }
PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment method.
type PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResponse ¶
type PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResponse contains the response from method PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment.
type PolicyStatesClientSummarizeForResourceGroupOptions ¶
type PolicyStatesClientSummarizeForResourceGroupOptions struct { }
PolicyStatesClientSummarizeForResourceGroupOptions contains the optional parameters for the PolicyStatesClient.SummarizeForResourceGroup method.
type PolicyStatesClientSummarizeForResourceGroupResponse ¶
type PolicyStatesClientSummarizeForResourceGroupResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForResourceGroupResponse contains the response from method PolicyStatesClient.SummarizeForResourceGroup.
type PolicyStatesClientSummarizeForResourceOptions ¶
type PolicyStatesClientSummarizeForResourceOptions struct { }
PolicyStatesClientSummarizeForResourceOptions contains the optional parameters for the PolicyStatesClient.SummarizeForResource method.
type PolicyStatesClientSummarizeForResourceResponse ¶
type PolicyStatesClientSummarizeForResourceResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForResourceResponse contains the response from method PolicyStatesClient.SummarizeForResource.
type PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentOptions ¶
type PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentOptions struct { }
PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters for the PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment method.
type PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResponse ¶
type PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResponse contains the response from method PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment.
type PolicyStatesClientSummarizeForSubscriptionOptions ¶
type PolicyStatesClientSummarizeForSubscriptionOptions struct { }
PolicyStatesClientSummarizeForSubscriptionOptions contains the optional parameters for the PolicyStatesClient.SummarizeForSubscription method.
type PolicyStatesClientSummarizeForSubscriptionResponse ¶
type PolicyStatesClientSummarizeForSubscriptionResponse struct { // Summarize action results. SummarizeResults }
PolicyStatesClientSummarizeForSubscriptionResponse contains the response from method PolicyStatesClient.SummarizeForSubscription.
type PolicyStatesClientTriggerResourceGroupEvaluationResponse ¶
type PolicyStatesClientTriggerResourceGroupEvaluationResponse struct { }
PolicyStatesClientTriggerResourceGroupEvaluationResponse contains the response from method PolicyStatesClient.BeginTriggerResourceGroupEvaluation.
type PolicyStatesClientTriggerSubscriptionEvaluationResponse ¶
type PolicyStatesClientTriggerSubscriptionEvaluationResponse struct { }
PolicyStatesClientTriggerSubscriptionEvaluationResponse contains the response from method PolicyStatesClient.BeginTriggerSubscriptionEvaluation.
type PolicyStatesQueryResults ¶
type PolicyStatesQueryResults struct { // OData context string; used by OData clients to resolve type information based on metadata. ODataContext *string // OData entity count; represents the number of policy state records returned. ODataCount *int32 // Odata next link; URL to get the next set of results. ODataNextLink *string // Query results. Value []*PolicyState }
PolicyStatesQueryResults - Query results.
func (PolicyStatesQueryResults) MarshalJSON ¶
func (p PolicyStatesQueryResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyStatesQueryResults.
func (*PolicyStatesQueryResults) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyStatesQueryResults) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyStatesQueryResults.
type PolicyStatesResource ¶
type PolicyStatesResource string
const ( PolicyStatesResourceDefault PolicyStatesResource = "default" PolicyStatesResourceLatest PolicyStatesResource = "latest" )
func PossiblePolicyStatesResourceValues ¶
func PossiblePolicyStatesResourceValues() []PolicyStatesResource
PossiblePolicyStatesResourceValues returns the possible values for the PolicyStatesResource const type.
type PolicyStatesSummaryResourceType ¶ added in v0.2.0
type PolicyStatesSummaryResourceType string
const (
PolicyStatesSummaryResourceTypeLatest PolicyStatesSummaryResourceType = "latest"
)
func PossiblePolicyStatesSummaryResourceTypeValues ¶ added in v0.2.0
func PossiblePolicyStatesSummaryResourceTypeValues() []PolicyStatesSummaryResourceType
PossiblePolicyStatesSummaryResourceTypeValues returns the possible values for the PolicyStatesSummaryResourceType const type.
type PolicyTrackedResource ¶
type PolicyTrackedResource struct { // READ-ONLY; The details of the policy triggered deployment that created the tracked resource. CreatedBy *TrackedResourceModificationDetails // READ-ONLY; The details of the policy triggered deployment that modified the tracked resource. LastModifiedBy *TrackedResourceModificationDetails // READ-ONLY; Timestamp of the last update to the tracked resource. LastUpdateUTC *time.Time // READ-ONLY; The details of the policy that require the tracked resource. PolicyDetails *PolicyDetails // READ-ONLY; The ID of the policy tracked resource. TrackedResourceID *string }
PolicyTrackedResource - Policy tracked resource record.
func (PolicyTrackedResource) MarshalJSON ¶
func (p PolicyTrackedResource) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyTrackedResource.
func (*PolicyTrackedResource) UnmarshalJSON ¶
func (p *PolicyTrackedResource) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyTrackedResource.
type PolicyTrackedResourcesClient ¶
type PolicyTrackedResourcesClient struct {
// contains filtered or unexported fields
}
PolicyTrackedResourcesClient contains the methods for the PolicyTrackedResources group. Don't use this type directly, use NewPolicyTrackedResourcesClient() instead.
func NewPolicyTrackedResourcesClient ¶
func NewPolicyTrackedResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyTrackedResourcesClient, error)
NewPolicyTrackedResourcesClient creates a new instance of PolicyTrackedResourcesClient with the specified values.
- subscriptionID - Microsoft Azure subscription ID.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*PolicyTrackedResourcesClient) NewListQueryResultsForManagementGroupPager ¶ added in v0.4.0
func (client *PolicyTrackedResourcesClient) NewListQueryResultsForManagementGroupPager(managementGroupName string, policyTrackedResourcesResource PolicyTrackedResourcesResourceType, queryOptions *QueryOptions, options *PolicyTrackedResourcesClientListQueryResultsForManagementGroupOptions) *runtime.Pager[PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse]
NewListQueryResultsForManagementGroupPager - Queries policy tracked resources under the management group.
Generated from API version 2018-07-01-preview
- managementGroupName - Management group name.
- policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default" is allowed.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyTrackedResourcesClientListQueryResultsForManagementGroupOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForManagementGroupPager method.
Example (QueryAtManagementGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForManagementGroupPager("myManagementGroup", armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment 1 Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment1"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition1"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName1"), // }, // { // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T00:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition2"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName2"), // }}, // } } }
Output:
Example (QueryAtManagementGroupScopeUsingQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryManagementGroupScopeWithFilterAndTop.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForManagementGroupPager("myManagementGroup", armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment' AND TrackedResourceId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName"), // }}, // } } }
Output:
func (*PolicyTrackedResourcesClient) NewListQueryResultsForResourceGroupPager ¶ added in v0.4.0
func (client *PolicyTrackedResourcesClient) NewListQueryResultsForResourceGroupPager(resourceGroupName string, policyTrackedResourcesResource PolicyTrackedResourcesResourceType, queryOptions *QueryOptions, options *PolicyTrackedResourcesClientListQueryResultsForResourceGroupOptions) *runtime.Pager[PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse]
NewListQueryResultsForResourceGroupPager - Queries policy tracked resources under the resource group.
Generated from API version 2018-07-01-preview
- resourceGroupName - Resource group name.
- policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default" is allowed.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyTrackedResourcesClientListQueryResultsForResourceGroupOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForResourceGroupPager method.
Example (QueryAtResourceGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForResourceGroupPager("myResourceGroup", armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment 1 Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment1"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition1"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName1"), // }, // { // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T00:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition2"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName2"), // }}, // } } }
Output:
Example (QueryAtResourceGroupScopeUsingQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceGroupScopeWithFilterAndTop.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForResourceGroupPager("myResourceGroup", armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment' AND TrackedResourceId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource/nestedResourceType/TrackedResource1'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment 1 Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment1"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition1"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource/nestedResourceType/TrackedResource1"), // }}, // } } }
Output:
func (*PolicyTrackedResourcesClient) NewListQueryResultsForResourcePager ¶ added in v0.4.0
func (client *PolicyTrackedResourcesClient) NewListQueryResultsForResourcePager(resourceID string, policyTrackedResourcesResource PolicyTrackedResourcesResourceType, queryOptions *QueryOptions, options *PolicyTrackedResourcesClientListQueryResultsForResourceOptions) *runtime.Pager[PolicyTrackedResourcesClientListQueryResultsForResourceResponse]
NewListQueryResultsForResourcePager - Queries policy tracked resources under the resource.
Generated from API version 2018-07-01-preview
- resourceID - Resource ID.
- policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default" is allowed.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyTrackedResourcesClientListQueryResultsForResourceOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForResourcePager method.
Example (QueryAtResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForResourcePager("subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource", armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment 1 Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment1"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition1"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource/nestedResourceType/TrackedResource1"), // }, // { // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T00:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition2"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource/nestedResourceType/TrackedResource2"), // }}, // } } }
Output:
Example (QueryAtResourceScopeUsingQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceScopeWithFilterAndTop.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForResourcePager("subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource", armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment' AND TrackedResourceId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource/nestedResourceType/TrackedResource1'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment 1 Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment1"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition1"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/myResource/nestedResourceType/TrackedResource1"), // }}, // } } }
Output:
func (*PolicyTrackedResourcesClient) NewListQueryResultsForSubscriptionPager ¶ added in v0.4.0
func (client *PolicyTrackedResourcesClient) NewListQueryResultsForSubscriptionPager(policyTrackedResourcesResource PolicyTrackedResourcesResourceType, queryOptions *QueryOptions, options *PolicyTrackedResourcesClientListQueryResultsForSubscriptionOptions) *runtime.Pager[PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse]
NewListQueryResultsForSubscriptionPager - Queries policy tracked resources under the subscription.
Generated from API version 2018-07-01-preview
- policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default" is allowed.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - PolicyTrackedResourcesClientListQueryResultsForSubscriptionOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForSubscriptionPager method.
Example (QueryAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QuerySubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment 1 Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment1"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition1"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName1"), // }, // { // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T00:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition2"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName2"), // }}, // } } }
Output:
Example (QueryAtSubscriptionScopeUsingQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QuerySubscriptionScopeWithFilterAndTop.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewPolicyTrackedResourcesClient().NewListQueryResultsForSubscriptionPager(armpolicyinsights.PolicyTrackedResourcesResourceTypeDefault, &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment' AND TrackedResourceId eq '/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.PolicyTrackedResourcesQueryResults = armpolicyinsights.PolicyTrackedResourcesQueryResults{ // Value: []*armpolicyinsights.PolicyTrackedResource{ // { // CreatedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/createdByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/createdByPolicyDefinition"), // }, // }, // LastModifiedBy: &armpolicyinsights.TrackedResourceModificationDetails{ // DeploymentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deploymentName"), // DeploymentTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-09T00:00:00.000Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/lastModifiedByPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/lastModifiedByPolicyDefinition"), // }, // }, // LastUpdateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T20:40:17.358Z"); return t}()), // PolicyDetails: &armpolicyinsights.PolicyDetails{ // PolicyAssignmentDisplayName: to.Ptr("My Policy Assignment Display name"), // PolicyAssignmentID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), // PolicyAssignmentScope: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/"), // PolicyDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Authorization/policyDefinitions/myPolicyDefinition"), // PolicyDefinitionReferenceID: to.Ptr("123ABC"), // PolicySetDefinitionID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/providers/Microsoft.Authorization/policySetDefinitions/mySetDefinition"), // }, // TrackedResourceID: to.Ptr("/subscriptions/fff8dfdb-fff3-fff0-fff4-fffdcbe6b2ef/resourceGroups/myResourceGroup/providers/Microsoft.Example/exampleResourceType/exampleTrackedResourceName"), // }}, // } } }
Output:
type PolicyTrackedResourcesClientListQueryResultsForManagementGroupOptions ¶
type PolicyTrackedResourcesClientListQueryResultsForManagementGroupOptions struct { }
PolicyTrackedResourcesClientListQueryResultsForManagementGroupOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForManagementGroupPager method.
type PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse ¶
type PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse struct { // Query results. PolicyTrackedResourcesQueryResults }
PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse contains the response from method PolicyTrackedResourcesClient.NewListQueryResultsForManagementGroupPager.
type PolicyTrackedResourcesClientListQueryResultsForResourceGroupOptions ¶
type PolicyTrackedResourcesClientListQueryResultsForResourceGroupOptions struct { }
PolicyTrackedResourcesClientListQueryResultsForResourceGroupOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForResourceGroupPager method.
type PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse ¶
type PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse struct { // Query results. PolicyTrackedResourcesQueryResults }
PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse contains the response from method PolicyTrackedResourcesClient.NewListQueryResultsForResourceGroupPager.
type PolicyTrackedResourcesClientListQueryResultsForResourceOptions ¶
type PolicyTrackedResourcesClientListQueryResultsForResourceOptions struct { }
PolicyTrackedResourcesClientListQueryResultsForResourceOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForResourcePager method.
type PolicyTrackedResourcesClientListQueryResultsForResourceResponse ¶
type PolicyTrackedResourcesClientListQueryResultsForResourceResponse struct { // Query results. PolicyTrackedResourcesQueryResults }
PolicyTrackedResourcesClientListQueryResultsForResourceResponse contains the response from method PolicyTrackedResourcesClient.NewListQueryResultsForResourcePager.
type PolicyTrackedResourcesClientListQueryResultsForSubscriptionOptions ¶
type PolicyTrackedResourcesClientListQueryResultsForSubscriptionOptions struct { }
PolicyTrackedResourcesClientListQueryResultsForSubscriptionOptions contains the optional parameters for the PolicyTrackedResourcesClient.NewListQueryResultsForSubscriptionPager method.
type PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse ¶
type PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse struct { // Query results. PolicyTrackedResourcesQueryResults }
PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse contains the response from method PolicyTrackedResourcesClient.NewListQueryResultsForSubscriptionPager.
type PolicyTrackedResourcesQueryResults ¶
type PolicyTrackedResourcesQueryResults struct { // READ-ONLY; The URL to get the next set of results. NextLink *string // READ-ONLY; Query results. Value []*PolicyTrackedResource }
PolicyTrackedResourcesQueryResults - Query results.
func (PolicyTrackedResourcesQueryResults) MarshalJSON ¶
func (p PolicyTrackedResourcesQueryResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type PolicyTrackedResourcesQueryResults.
func (*PolicyTrackedResourcesQueryResults) UnmarshalJSON ¶ added in v0.6.0
func (p *PolicyTrackedResourcesQueryResults) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type PolicyTrackedResourcesQueryResults.
type PolicyTrackedResourcesResourceType ¶ added in v0.2.0
type PolicyTrackedResourcesResourceType string
const (
PolicyTrackedResourcesResourceTypeDefault PolicyTrackedResourcesResourceType = "default"
)
func PossiblePolicyTrackedResourcesResourceTypeValues ¶ added in v0.2.0
func PossiblePolicyTrackedResourcesResourceTypeValues() []PolicyTrackedResourcesResourceType
PossiblePolicyTrackedResourcesResourceTypeValues returns the possible values for the PolicyTrackedResourcesResourceType const type.
type QueryFailure ¶
type QueryFailure struct { // Error definition. Error *QueryFailureError }
QueryFailure - Error response.
func (QueryFailure) MarshalJSON ¶ added in v0.6.0
func (q QueryFailure) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type QueryFailure.
func (*QueryFailure) UnmarshalJSON ¶ added in v0.6.0
func (q *QueryFailure) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type QueryFailure.
type QueryFailureError ¶
type QueryFailureError struct { // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. Code *string // READ-ONLY; Description of the error. Message *string }
QueryFailureError - Error definition.
func (QueryFailureError) MarshalJSON ¶ added in v0.6.0
func (q QueryFailureError) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type QueryFailureError.
func (*QueryFailureError) UnmarshalJSON ¶ added in v0.6.0
func (q *QueryFailureError) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type QueryFailureError.
type QueryOptions ¶
type QueryOptions struct { // OData apply expression for aggregations. Apply *string // The $expand query parameter. For example, to expand components use $expand=components Expand *string // OData filter expression. Filter *string // ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to // - 1-day). From *time.Time // 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". OrderBy *string // Select expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, // ResourceId". Select *string // Skiptoken is only provided if a previous response returned a partial result as a part of nextLink element. SkipToken *string // ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request // time. To *time.Time // Maximum number of records to return. Top *int32 }
QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
type Remediation ¶
type Remediation struct { // Properties for the remediation. Properties *RemediationProperties // READ-ONLY; The ID of the remediation. ID *string // READ-ONLY; The name of the remediation. Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the remediation. Type *string }
Remediation - The remediation definition.
func (Remediation) MarshalJSON ¶ added in v0.6.0
func (r Remediation) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type Remediation.
func (*Remediation) UnmarshalJSON ¶ added in v0.6.0
func (r *Remediation) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type Remediation.
type RemediationDeployment ¶
type RemediationDeployment struct { // READ-ONLY; The time at which the remediation was created. CreatedOn *time.Time // READ-ONLY; Resource ID of the template deployment that will remediate the resource. DeploymentID *string // READ-ONLY; Error encountered while remediated the resource. Error *ErrorDefinition // READ-ONLY; The time at which the remediation deployment was last updated. LastUpdatedOn *time.Time // READ-ONLY; Resource ID of the resource that is being remediated by the deployment. RemediatedResourceID *string // READ-ONLY; Location of the resource that is being remediated. ResourceLocation *string // READ-ONLY; Status of the remediation deployment. Status *string }
RemediationDeployment - Details of a single deployment created by the remediation.
func (RemediationDeployment) MarshalJSON ¶
func (r RemediationDeployment) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationDeployment.
func (*RemediationDeployment) UnmarshalJSON ¶
func (r *RemediationDeployment) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationDeployment.
type RemediationDeploymentSummary ¶
type RemediationDeploymentSummary struct { // READ-ONLY; The number of deployments required by the remediation that have failed. FailedDeployments *int32 // READ-ONLY; The number of deployments required by the remediation that have succeeded. SuccessfulDeployments *int32 // READ-ONLY; The number of deployments required by the remediation. TotalDeployments *int32 }
RemediationDeploymentSummary - The deployment status summary for all deployments created by the remediation.
func (RemediationDeploymentSummary) MarshalJSON ¶ added in v0.6.0
func (r RemediationDeploymentSummary) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationDeploymentSummary.
func (*RemediationDeploymentSummary) UnmarshalJSON ¶ added in v0.6.0
func (r *RemediationDeploymentSummary) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationDeploymentSummary.
type RemediationDeploymentsListResult ¶
type RemediationDeploymentsListResult struct { // READ-ONLY; The URL to get the next set of results. NextLink *string // READ-ONLY; Array of deployments for the remediation. Value []*RemediationDeployment }
RemediationDeploymentsListResult - List of deployments for a remediation.
func (RemediationDeploymentsListResult) MarshalJSON ¶
func (r RemediationDeploymentsListResult) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationDeploymentsListResult.
func (*RemediationDeploymentsListResult) UnmarshalJSON ¶ added in v0.6.0
func (r *RemediationDeploymentsListResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationDeploymentsListResult.
type RemediationFilters ¶
type RemediationFilters struct { // The resource locations that will be remediated. Locations []*string }
RemediationFilters - The filters that will be applied to determine which resources to remediate.
func (RemediationFilters) MarshalJSON ¶
func (r RemediationFilters) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationFilters.
func (*RemediationFilters) UnmarshalJSON ¶ added in v0.6.0
func (r *RemediationFilters) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationFilters.
type RemediationListResult ¶
type RemediationListResult struct { // READ-ONLY; The URL to get the next set of results. NextLink *string // READ-ONLY; Array of remediation definitions. Value []*Remediation }
RemediationListResult - List of remediations.
func (RemediationListResult) MarshalJSON ¶
func (r RemediationListResult) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationListResult.
func (*RemediationListResult) UnmarshalJSON ¶ added in v0.6.0
func (r *RemediationListResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationListResult.
type RemediationProperties ¶
type RemediationProperties struct { // The remediation failure threshold settings FailureThreshold *RemediationPropertiesFailureThreshold // The filters that will be applied to determine which resources to remediate. Filters *RemediationFilters // Determines how many resources to remediate at any given time. Can be used to increase or reduce the pace of the remediation. // If not provided, the default parallel deployments value is used. ParallelDeployments *int32 // The resource ID of the policy assignment that should be remediated. PolicyAssignmentID *string // 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. PolicyDefinitionReferenceID *string // Determines the max number of resources that can be remediated by the remediation job. If not provided, the default resource // count is used. ResourceCount *int32 // The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified. ResourceDiscoveryMode *ResourceDiscoveryMode // READ-ONLY; The remediation correlation Id. Can be used to find events related to the remediation in the activity log. CorrelationID *string // READ-ONLY; The time at which the remediation was created. CreatedOn *time.Time // READ-ONLY; The deployment status summary for all deployments created by the remediation. DeploymentStatus *RemediationDeploymentSummary // READ-ONLY; The time at which the remediation was last updated. LastUpdatedOn *time.Time // READ-ONLY; The status of the remediation. ProvisioningState *string // READ-ONLY; The remediation status message. Provides additional details regarding the state of the remediation. StatusMessage *string }
RemediationProperties - The remediation properties.
func (RemediationProperties) MarshalJSON ¶
func (r RemediationProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationProperties.
func (*RemediationProperties) UnmarshalJSON ¶
func (r *RemediationProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationProperties.
type RemediationPropertiesFailureThreshold ¶
type RemediationPropertiesFailureThreshold struct { // A number between 0.0 to 1.0 representing the percentage failure threshold. The remediation will fail if the percentage // of failed remediation operations (i.e. failed deployments) exceeds this // threshold. Percentage *float32 }
RemediationPropertiesFailureThreshold - The remediation failure threshold settings
func (RemediationPropertiesFailureThreshold) MarshalJSON ¶ added in v0.6.0
func (r RemediationPropertiesFailureThreshold) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type RemediationPropertiesFailureThreshold.
func (*RemediationPropertiesFailureThreshold) UnmarshalJSON ¶ added in v0.6.0
func (r *RemediationPropertiesFailureThreshold) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type RemediationPropertiesFailureThreshold.
type RemediationsClient ¶
type RemediationsClient struct {
// contains filtered or unexported fields
}
RemediationsClient contains the methods for the Remediations group. Don't use this type directly, use NewRemediationsClient() instead.
func NewRemediationsClient ¶
func NewRemediationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RemediationsClient, error)
NewRemediationsClient creates a new instance of RemediationsClient with the specified values.
- subscriptionID - Microsoft Azure subscription ID.
- credential - used to authorize requests. Usually a credential from azidentity.
- options - pass nil to accept the default values.
func (*RemediationsClient) CancelAtManagementGroup ¶
func (client *RemediationsClient) CancelAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, options *RemediationsClientCancelAtManagementGroupOptions) (RemediationsClientCancelAtManagementGroupResponse, error)
CancelAtManagementGroup - Cancels a remediation at management group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- managementGroupID - Management group ID.
- remediationName - The name of the remediation.
- options - RemediationsClientCancelAtManagementGroupOptions contains the optional parameters for the RemediationsClient.CancelAtManagementGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CancelAtManagementGroup(ctx, "financeMg", "myRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("myRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/myRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) CancelAtResource ¶
func (client *RemediationsClient) CancelAtResource(ctx context.Context, resourceID string, remediationName string, options *RemediationsClientCancelAtResourceOptions) (RemediationsClientCancelAtResourceResponse, error)
CancelAtResource - Cancel a remediation at resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceID - Resource ID.
- remediationName - The name of the remediation.
- options - RemediationsClientCancelAtResourceOptions contains the optional parameters for the RemediationsClient.CancelAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CancelAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", "myRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("myRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1/providers/microsoft.policyinsights/remediations/myRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.085Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](1), // TotalDeployments: to.Ptr[int32](1), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) CancelAtResourceGroup ¶
func (client *RemediationsClient) CancelAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, options *RemediationsClientCancelAtResourceGroupOptions) (RemediationsClientCancelAtResourceGroupResponse, error)
CancelAtResourceGroup - Cancels a remediation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceGroupName - Resource group name.
- remediationName - The name of the remediation.
- options - RemediationsClientCancelAtResourceGroupOptions contains the optional parameters for the RemediationsClient.CancelAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CancelAtResourceGroup(ctx, "myResourceGroup", "myRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("myRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/myRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) CancelAtSubscription ¶
func (client *RemediationsClient) CancelAtSubscription(ctx context.Context, remediationName string, options *RemediationsClientCancelAtSubscriptionOptions) (RemediationsClientCancelAtSubscriptionResponse, error)
CancelAtSubscription - Cancels a remediation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- remediationName - The name of the remediation.
- options - RemediationsClientCancelAtSubscriptionOptions contains the optional parameters for the RemediationsClient.CancelAtSubscription method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CancelAtSubscription(ctx, "myRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("myRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/myRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) CreateOrUpdateAtManagementGroup ¶
func (client *RemediationsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, parameters Remediation, options *RemediationsClientCreateOrUpdateAtManagementGroupOptions) (RemediationsClientCreateOrUpdateAtManagementGroupResponse, error)
CreateOrUpdateAtManagementGroup - Creates or updates a remediation at management group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- managementGroupID - Management group ID.
- remediationName - The name of the remediation.
- parameters - The remediation parameters.
- options - RemediationsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtManagementGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CreateOrUpdateAtManagementGroup(ctx, "financeMg", "storageRemediation", armpolicyinsights.Remediation{ Properties: &armpolicyinsights.RemediationProperties{ PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](0), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // } }
Output:
func (*RemediationsClient) CreateOrUpdateAtResource ¶
func (client *RemediationsClient) CreateOrUpdateAtResource(ctx context.Context, resourceID string, remediationName string, parameters Remediation, options *RemediationsClientCreateOrUpdateAtResourceOptions) (RemediationsClientCreateOrUpdateAtResourceResponse, error)
CreateOrUpdateAtResource - Creates or updates a remediation at resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceID - Resource ID.
- remediationName - The name of the remediation.
- parameters - The remediation parameters.
- options - RemediationsClientCreateOrUpdateAtResourceOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CreateOrUpdateAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", "storageRemediation", armpolicyinsights.Remediation{ Properties: &armpolicyinsights.RemediationProperties{ PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](0), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) CreateOrUpdateAtResourceGroup ¶
func (client *RemediationsClient) CreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, parameters Remediation, options *RemediationsClientCreateOrUpdateAtResourceGroupOptions) (RemediationsClientCreateOrUpdateAtResourceGroupResponse, error)
CreateOrUpdateAtResourceGroup - Creates or updates a remediation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceGroupName - Resource group name.
- remediationName - The name of the remediation.
- parameters - The remediation parameters.
- options - RemediationsClientCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CreateOrUpdateAtResourceGroup(ctx, "myResourceGroup", "storageRemediation", armpolicyinsights.Remediation{ Properties: &armpolicyinsights.RemediationProperties{ PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](0), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) CreateOrUpdateAtSubscription ¶
func (client *RemediationsClient) CreateOrUpdateAtSubscription(ctx context.Context, remediationName string, parameters Remediation, options *RemediationsClientCreateOrUpdateAtSubscriptionOptions) (RemediationsClientCreateOrUpdateAtSubscriptionResponse, error)
CreateOrUpdateAtSubscription - Creates or updates a remediation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- remediationName - The name of the remediation.
- parameters - The remediation parameters.
- options - RemediationsClientCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtSubscription method.
Example (CreateRemediationAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CreateOrUpdateAtSubscription(ctx, "storageRemediation", armpolicyinsights.Remediation{ Properties: &armpolicyinsights.RemediationProperties{ PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](0), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
Example (CreateRemediationAtSubscriptionScopeWithAllProperties) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateSubscriptionScope_AllProperties.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().CreateOrUpdateAtSubscription(ctx, "storageRemediation", armpolicyinsights.Remediation{ Properties: &armpolicyinsights.RemediationProperties{ FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ Percentage: to.Ptr[float32](0.1), }, Filters: &armpolicyinsights.RemediationFilters{ Locations: []*string{ to.Ptr("eastus"), to.Ptr("westus")}, }, ParallelDeployments: to.Ptr[int32](6), PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), PolicyDefinitionReferenceID: to.Ptr("8c8fa9e4"), ResourceCount: to.Ptr[int32](42), ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeReEvaluateCompliance), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](0), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("8c8fa9e4"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeReEvaluateCompliance), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-12T20:58:58.753Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) DeleteAtManagementGroup ¶
func (client *RemediationsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, options *RemediationsClientDeleteAtManagementGroupOptions) (RemediationsClientDeleteAtManagementGroupResponse, error)
DeleteAtManagementGroup - Deletes an existing remediation at management group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- managementGroupID - Management group ID.
- remediationName - The name of the remediation.
- options - RemediationsClientDeleteAtManagementGroupOptions contains the optional parameters for the RemediationsClient.DeleteAtManagementGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().DeleteAtManagementGroup(ctx, "financeMg", "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) DeleteAtResource ¶
func (client *RemediationsClient) DeleteAtResource(ctx context.Context, resourceID string, remediationName string, options *RemediationsClientDeleteAtResourceOptions) (RemediationsClientDeleteAtResourceResponse, error)
DeleteAtResource - Deletes an existing remediation at individual resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceID - Resource ID.
- remediationName - The name of the remediation.
- options - RemediationsClientDeleteAtResourceOptions contains the optional parameters for the RemediationsClient.DeleteAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().DeleteAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](1), // TotalDeployments: to.Ptr[int32](1), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) DeleteAtResourceGroup ¶
func (client *RemediationsClient) DeleteAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, options *RemediationsClientDeleteAtResourceGroupOptions) (RemediationsClientDeleteAtResourceGroupResponse, error)
DeleteAtResourceGroup - Deletes an existing remediation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceGroupName - Resource group name.
- remediationName - The name of the remediation.
- options - RemediationsClientDeleteAtResourceGroupOptions contains the optional parameters for the RemediationsClient.DeleteAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().DeleteAtResourceGroup(ctx, "myResourceGroup", "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) DeleteAtSubscription ¶
func (client *RemediationsClient) DeleteAtSubscription(ctx context.Context, remediationName string, options *RemediationsClientDeleteAtSubscriptionOptions) (RemediationsClientDeleteAtSubscriptionResponse, error)
DeleteAtSubscription - Deletes an existing remediation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- remediationName - The name of the remediation.
- options - RemediationsClientDeleteAtSubscriptionOptions contains the optional parameters for the RemediationsClient.DeleteAtSubscription method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().DeleteAtSubscription(ctx, "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) GetAtManagementGroup ¶
func (client *RemediationsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, options *RemediationsClientGetAtManagementGroupOptions) (RemediationsClientGetAtManagementGroupResponse, error)
GetAtManagementGroup - Gets an existing remediation at management group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- managementGroupID - Management group ID.
- remediationName - The name of the remediation.
- options - RemediationsClientGetAtManagementGroupOptions contains the optional parameters for the RemediationsClient.GetAtManagementGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().GetAtManagementGroup(ctx, "financeMg", "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) GetAtResource ¶
func (client *RemediationsClient) GetAtResource(ctx context.Context, resourceID string, remediationName string, options *RemediationsClientGetAtResourceOptions) (RemediationsClientGetAtResourceResponse, error)
GetAtResource - Gets an existing remediation at resource scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceID - Resource ID.
- remediationName - The name of the remediation.
- options - RemediationsClientGetAtResourceOptions contains the optional parameters for the RemediationsClient.GetAtResource method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().GetAtResource(ctx, "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](1), // TotalDeployments: to.Ptr[int32](1), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) GetAtResourceGroup ¶
func (client *RemediationsClient) GetAtResourceGroup(ctx context.Context, resourceGroupName string, remediationName string, options *RemediationsClientGetAtResourceGroupOptions) (RemediationsClientGetAtResourceGroupResponse, error)
GetAtResourceGroup - Gets an existing remediation at resource group scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- resourceGroupName - Resource group name.
- remediationName - The name of the remediation.
- options - RemediationsClientGetAtResourceGroupOptions contains the optional parameters for the RemediationsClient.GetAtResourceGroup method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().GetAtResourceGroup(ctx, "myResourceGroup", "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) GetAtSubscription ¶
func (client *RemediationsClient) GetAtSubscription(ctx context.Context, remediationName string, options *RemediationsClientGetAtSubscriptionOptions) (RemediationsClientGetAtSubscriptionResponse, error)
GetAtSubscription - Gets an existing remediation at subscription scope. If the operation fails it returns an *azcore.ResponseError type.
Generated from API version 2021-10-01
- remediationName - The name of the remediation.
- options - RemediationsClientGetAtSubscriptionOptions contains the optional parameters for the RemediationsClient.GetAtSubscription method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewRemediationsClient().GetAtSubscription(ctx, "storageRemediation", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Remediation = armpolicyinsights.Remediation{ // Name: to.Ptr("storageRemediation"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/storageRemediation"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // } }
Output:
func (*RemediationsClient) NewListDeploymentsAtManagementGroupPager ¶ added in v0.4.0
func (client *RemediationsClient) NewListDeploymentsAtManagementGroupPager(managementGroupID string, remediationName string, queryOptions *QueryOptions, options *RemediationsClientListDeploymentsAtManagementGroupOptions) *runtime.Pager[RemediationsClientListDeploymentsAtManagementGroupResponse]
NewListDeploymentsAtManagementGroupPager - Gets all deployments for a remediation at management group scope.
Generated from API version 2021-10-01
- managementGroupID - Management group ID.
- remediationName - The name of the remediation.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListDeploymentsAtManagementGroupOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtManagementGroupPager method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListDeploymentsAtManagementGroupPager("financeMg", "myRemediation", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationDeploymentsListResult = armpolicyinsights.RemediationDeploymentsListResult{ // Value: []*armpolicyinsights.RemediationDeployment{ // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.resources/deployments/a088e8fd-8600-4126-8d74-fc7ead0e9ae4"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.891Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"), // ResourceLocation: to.Ptr("eastus"), // Status: to.Ptr("Succeeded"), // }, // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/c1164d71-0942-499f-bc2f-b6b7b0bae493/resourcegroups/myResourceGroup2/providers/microsoft.resources/deployments/6b8898c0-18a2-449e-987a-8d4d4f634f56"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.876Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/c1164d71-0942-499f-bc2f-b6b7b0bae493/resourcegroups/myResourceGroup2/providers/microsoft.storage/storageaccounts/stor1"), // ResourceLocation: to.Ptr("westus"), // Status: to.Ptr("Succeeded"), // }}, // } } }
Output:
func (*RemediationsClient) NewListDeploymentsAtResourceGroupPager ¶ added in v0.4.0
func (client *RemediationsClient) NewListDeploymentsAtResourceGroupPager(resourceGroupName string, remediationName string, queryOptions *QueryOptions, options *RemediationsClientListDeploymentsAtResourceGroupOptions) *runtime.Pager[RemediationsClientListDeploymentsAtResourceGroupResponse]
NewListDeploymentsAtResourceGroupPager - Gets all deployments for a remediation at resource group scope.
Generated from API version 2021-10-01
- resourceGroupName - Resource group name.
- remediationName - The name of the remediation.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListDeploymentsAtResourceGroupOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtResourceGroupPager method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListDeploymentsAtResourceGroupPager("myResourceGroup", "myRemediation", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationDeploymentsListResult = armpolicyinsights.RemediationDeploymentsListResult{ // Value: []*armpolicyinsights.RemediationDeployment{ // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.resources/deployments/a088e8fd-8600-4126-8d74-fc7ead0e9ae4"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.891Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"), // ResourceLocation: to.Ptr("eastus"), // Status: to.Ptr("Succeeded"), // }, // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.resources/deployments/6b8898c0-18a2-449e-987a-8d4d4f634f56"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.876Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/stor2"), // ResourceLocation: to.Ptr("westus"), // Status: to.Ptr("Succeeded"), // }}, // } } }
Output:
func (*RemediationsClient) NewListDeploymentsAtResourcePager ¶ added in v0.4.0
func (client *RemediationsClient) NewListDeploymentsAtResourcePager(resourceID string, remediationName string, queryOptions *QueryOptions, options *RemediationsClientListDeploymentsAtResourceOptions) *runtime.Pager[RemediationsClientListDeploymentsAtResourceResponse]
NewListDeploymentsAtResourcePager - Gets all deployments for a remediation at resource scope.
Generated from API version 2021-10-01
- resourceID - Resource ID.
- remediationName - The name of the remediation.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListDeploymentsAtResourceOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtResourcePager method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListDeploymentsAtResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", "myRemediation", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationDeploymentsListResult = armpolicyinsights.RemediationDeploymentsListResult{ // Value: []*armpolicyinsights.RemediationDeployment{ // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.resources/deployments/a088e8fd-8600-4126-8d74-fc7ead0e9ae4"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.891Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"), // ResourceLocation: to.Ptr("eastus"), // Status: to.Ptr("Succeeded"), // }}, // } } }
Output:
func (*RemediationsClient) NewListDeploymentsAtSubscriptionPager ¶ added in v0.4.0
func (client *RemediationsClient) NewListDeploymentsAtSubscriptionPager(remediationName string, queryOptions *QueryOptions, options *RemediationsClientListDeploymentsAtSubscriptionOptions) *runtime.Pager[RemediationsClientListDeploymentsAtSubscriptionResponse]
NewListDeploymentsAtSubscriptionPager - Gets all deployments for a remediation at subscription scope.
Generated from API version 2021-10-01
- remediationName - The name of the remediation.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListDeploymentsAtSubscriptionOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtSubscriptionPager method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListDeploymentsAtSubscriptionPager("myRemediation", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationDeploymentsListResult = armpolicyinsights.RemediationDeploymentsListResult{ // Value: []*armpolicyinsights.RemediationDeployment{ // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.resources/deployments/a088e8fd-8600-4126-8d74-fc7ead0e9ae4"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.891Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"), // ResourceLocation: to.Ptr("eastus"), // Status: to.Ptr("Succeeded"), // }, // { // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.resources/deployments/6b8898c0-18a2-449e-987a-8d4d4f634f56"), // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:09.876Z"); return t}()), // RemediatedResourceID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.storage/storageaccounts/stor1"), // ResourceLocation: to.Ptr("westus"), // Status: to.Ptr("Succeeded"), // }}, // } } }
Output:
func (*RemediationsClient) NewListForManagementGroupPager ¶ added in v0.4.0
func (client *RemediationsClient) NewListForManagementGroupPager(managementGroupID string, queryOptions *QueryOptions, options *RemediationsClientListForManagementGroupOptions) *runtime.Pager[RemediationsClientListForManagementGroupResponse]
NewListForManagementGroupPager - Gets all remediations for the management group.
Generated from API version 2021-10-01
- managementGroupID - Management group ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListForManagementGroupOptions contains the optional parameters for the RemediationsClient.NewListForManagementGroupPager method.
Example (ListRemediationsAtManagementGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListManagementGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForManagementGroupPager("financeMg", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListRemediationsAtManagementGroupScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListManagementGroupScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForManagementGroupPager("financeMg", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/financeMg/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/providers/microsoft.management/managementGroups/financeMg/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
func (*RemediationsClient) NewListForResourceGroupPager ¶ added in v0.4.0
func (client *RemediationsClient) NewListForResourceGroupPager(resourceGroupName string, queryOptions *QueryOptions, options *RemediationsClientListForResourceGroupOptions) *runtime.Pager[RemediationsClientListForResourceGroupResponse]
NewListForResourceGroupPager - Gets all remediations for the subscription.
Generated from API version 2021-10-01
- resourceGroupName - Resource group name.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListForResourceGroupOptions contains the optional parameters for the RemediationsClient.NewListForResourceGroupPager method.
Example (ListRemediationsAtResourceGroupScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceGroupScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForResourceGroupPager("myResourceGroup", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListRemediationsAtResourceGroupScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceGroupScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForResourceGroupPager("myResourceGroup", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
func (*RemediationsClient) NewListForResourcePager ¶ added in v0.4.0
func (client *RemediationsClient) NewListForResourcePager(resourceID string, queryOptions *QueryOptions, options *RemediationsClientListForResourceOptions) *runtime.Pager[RemediationsClientListForResourceResponse]
NewListForResourcePager - Gets all remediations for a resource.
Generated from API version 2021-10-01
- resourceID - Resource ID.
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListForResourceOptions contains the optional parameters for the RemediationsClient.NewListForResourcePager method.
Example (ListRemediationsAtIndividualResourceScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", &armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](1), // TotalDeployments: to.Ptr[int32](1), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListRemediationsAtIndividualResourceScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1", &armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](1), // TotalDeployments: to.Ptr[int32](1), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
func (*RemediationsClient) NewListForSubscriptionPager ¶ added in v0.4.0
func (client *RemediationsClient) NewListForSubscriptionPager(queryOptions *QueryOptions, options *RemediationsClientListForSubscriptionOptions) *runtime.Pager[RemediationsClientListForSubscriptionResponse]
NewListForSubscriptionPager - Gets all remediations for the subscription.
Generated from API version 2021-10-01
- QueryOptions - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup method.
- options - RemediationsClientListForSubscriptionOptions contains the optional parameters for the RemediationsClient.NewListForSubscriptionPager method.
Example (ListRemediationsAtSubscriptionScope) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForSubscriptionPager(&armpolicyinsights.QueryOptions{Top: nil, Filter: nil, OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
Example (ListRemediationsAtSubscriptionScopeWithQueryParameters) ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json
package main import ( "context" "log" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" ) func main() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewRemediationsClient().NewListForSubscriptionPager(&armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1), Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq 'storageSkuDef'"), OrderBy: nil, Select: nil, From: nil, To: nil, Apply: nil, SkipToken: nil, Expand: nil, }, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { // You could use page here. We use blank identifier for just demo purposes. _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.RemediationListResult = armpolicyinsights.RemediationListResult{ // Value: []*armpolicyinsights.Remediation{ // { // Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{ // Percentage: to.Ptr[float32](0.1), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()), // ParallelDeployments: to.Ptr[int32](6), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("storageSkuDef"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceCount: to.Ptr[int32](42), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }, // { // Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Type: to.Ptr("Microsoft.PolicyInsights/remediations"), // ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/rg2/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"), // Properties: &armpolicyinsights.RemediationProperties{ // CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"), // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{ // FailedDeployments: to.Ptr[int32](0), // SuccessfulDeployments: to.Ptr[int32](2), // TotalDeployments: to.Ptr[int32](2), // }, // LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), // PolicyDefinitionReferenceID: to.Ptr("storageSkuDef"), // ProvisioningState: to.Ptr("Succeeded"), // ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant), // StatusMessage: to.Ptr("Remediation extended status"), // }, // SystemData: &armpolicyinsights.SystemData{ // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()), // CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()), // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), // }, // }}, // } } }
Output:
type RemediationsClientCancelAtManagementGroupOptions ¶
type RemediationsClientCancelAtManagementGroupOptions struct { }
RemediationsClientCancelAtManagementGroupOptions contains the optional parameters for the RemediationsClient.CancelAtManagementGroup method.
type RemediationsClientCancelAtManagementGroupResponse ¶
type RemediationsClientCancelAtManagementGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientCancelAtManagementGroupResponse contains the response from method RemediationsClient.CancelAtManagementGroup.
type RemediationsClientCancelAtResourceGroupOptions ¶
type RemediationsClientCancelAtResourceGroupOptions struct { }
RemediationsClientCancelAtResourceGroupOptions contains the optional parameters for the RemediationsClient.CancelAtResourceGroup method.
type RemediationsClientCancelAtResourceGroupResponse ¶
type RemediationsClientCancelAtResourceGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientCancelAtResourceGroupResponse contains the response from method RemediationsClient.CancelAtResourceGroup.
type RemediationsClientCancelAtResourceOptions ¶
type RemediationsClientCancelAtResourceOptions struct { }
RemediationsClientCancelAtResourceOptions contains the optional parameters for the RemediationsClient.CancelAtResource method.
type RemediationsClientCancelAtResourceResponse ¶
type RemediationsClientCancelAtResourceResponse struct { // The remediation definition. Remediation }
RemediationsClientCancelAtResourceResponse contains the response from method RemediationsClient.CancelAtResource.
type RemediationsClientCancelAtSubscriptionOptions ¶
type RemediationsClientCancelAtSubscriptionOptions struct { }
RemediationsClientCancelAtSubscriptionOptions contains the optional parameters for the RemediationsClient.CancelAtSubscription method.
type RemediationsClientCancelAtSubscriptionResponse ¶
type RemediationsClientCancelAtSubscriptionResponse struct { // The remediation definition. Remediation }
RemediationsClientCancelAtSubscriptionResponse contains the response from method RemediationsClient.CancelAtSubscription.
type RemediationsClientCreateOrUpdateAtManagementGroupOptions ¶
type RemediationsClientCreateOrUpdateAtManagementGroupOptions struct { }
RemediationsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtManagementGroup method.
type RemediationsClientCreateOrUpdateAtManagementGroupResponse ¶
type RemediationsClientCreateOrUpdateAtManagementGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientCreateOrUpdateAtManagementGroupResponse contains the response from method RemediationsClient.CreateOrUpdateAtManagementGroup.
type RemediationsClientCreateOrUpdateAtResourceGroupOptions ¶
type RemediationsClientCreateOrUpdateAtResourceGroupOptions struct { }
RemediationsClientCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtResourceGroup method.
type RemediationsClientCreateOrUpdateAtResourceGroupResponse ¶
type RemediationsClientCreateOrUpdateAtResourceGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientCreateOrUpdateAtResourceGroupResponse contains the response from method RemediationsClient.CreateOrUpdateAtResourceGroup.
type RemediationsClientCreateOrUpdateAtResourceOptions ¶
type RemediationsClientCreateOrUpdateAtResourceOptions struct { }
RemediationsClientCreateOrUpdateAtResourceOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtResource method.
type RemediationsClientCreateOrUpdateAtResourceResponse ¶
type RemediationsClientCreateOrUpdateAtResourceResponse struct { // The remediation definition. Remediation }
RemediationsClientCreateOrUpdateAtResourceResponse contains the response from method RemediationsClient.CreateOrUpdateAtResource.
type RemediationsClientCreateOrUpdateAtSubscriptionOptions ¶
type RemediationsClientCreateOrUpdateAtSubscriptionOptions struct { }
RemediationsClientCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the RemediationsClient.CreateOrUpdateAtSubscription method.
type RemediationsClientCreateOrUpdateAtSubscriptionResponse ¶
type RemediationsClientCreateOrUpdateAtSubscriptionResponse struct { // The remediation definition. Remediation }
RemediationsClientCreateOrUpdateAtSubscriptionResponse contains the response from method RemediationsClient.CreateOrUpdateAtSubscription.
type RemediationsClientDeleteAtManagementGroupOptions ¶
type RemediationsClientDeleteAtManagementGroupOptions struct { }
RemediationsClientDeleteAtManagementGroupOptions contains the optional parameters for the RemediationsClient.DeleteAtManagementGroup method.
type RemediationsClientDeleteAtManagementGroupResponse ¶
type RemediationsClientDeleteAtManagementGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientDeleteAtManagementGroupResponse contains the response from method RemediationsClient.DeleteAtManagementGroup.
type RemediationsClientDeleteAtResourceGroupOptions ¶
type RemediationsClientDeleteAtResourceGroupOptions struct { }
RemediationsClientDeleteAtResourceGroupOptions contains the optional parameters for the RemediationsClient.DeleteAtResourceGroup method.
type RemediationsClientDeleteAtResourceGroupResponse ¶
type RemediationsClientDeleteAtResourceGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientDeleteAtResourceGroupResponse contains the response from method RemediationsClient.DeleteAtResourceGroup.
type RemediationsClientDeleteAtResourceOptions ¶
type RemediationsClientDeleteAtResourceOptions struct { }
RemediationsClientDeleteAtResourceOptions contains the optional parameters for the RemediationsClient.DeleteAtResource method.
type RemediationsClientDeleteAtResourceResponse ¶
type RemediationsClientDeleteAtResourceResponse struct { // The remediation definition. Remediation }
RemediationsClientDeleteAtResourceResponse contains the response from method RemediationsClient.DeleteAtResource.
type RemediationsClientDeleteAtSubscriptionOptions ¶
type RemediationsClientDeleteAtSubscriptionOptions struct { }
RemediationsClientDeleteAtSubscriptionOptions contains the optional parameters for the RemediationsClient.DeleteAtSubscription method.
type RemediationsClientDeleteAtSubscriptionResponse ¶
type RemediationsClientDeleteAtSubscriptionResponse struct { // The remediation definition. Remediation }
RemediationsClientDeleteAtSubscriptionResponse contains the response from method RemediationsClient.DeleteAtSubscription.
type RemediationsClientGetAtManagementGroupOptions ¶
type RemediationsClientGetAtManagementGroupOptions struct { }
RemediationsClientGetAtManagementGroupOptions contains the optional parameters for the RemediationsClient.GetAtManagementGroup method.
type RemediationsClientGetAtManagementGroupResponse ¶
type RemediationsClientGetAtManagementGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientGetAtManagementGroupResponse contains the response from method RemediationsClient.GetAtManagementGroup.
type RemediationsClientGetAtResourceGroupOptions ¶
type RemediationsClientGetAtResourceGroupOptions struct { }
RemediationsClientGetAtResourceGroupOptions contains the optional parameters for the RemediationsClient.GetAtResourceGroup method.
type RemediationsClientGetAtResourceGroupResponse ¶
type RemediationsClientGetAtResourceGroupResponse struct { // The remediation definition. Remediation }
RemediationsClientGetAtResourceGroupResponse contains the response from method RemediationsClient.GetAtResourceGroup.
type RemediationsClientGetAtResourceOptions ¶
type RemediationsClientGetAtResourceOptions struct { }
RemediationsClientGetAtResourceOptions contains the optional parameters for the RemediationsClient.GetAtResource method.
type RemediationsClientGetAtResourceResponse ¶
type RemediationsClientGetAtResourceResponse struct { // The remediation definition. Remediation }
RemediationsClientGetAtResourceResponse contains the response from method RemediationsClient.GetAtResource.
type RemediationsClientGetAtSubscriptionOptions ¶
type RemediationsClientGetAtSubscriptionOptions struct { }
RemediationsClientGetAtSubscriptionOptions contains the optional parameters for the RemediationsClient.GetAtSubscription method.
type RemediationsClientGetAtSubscriptionResponse ¶
type RemediationsClientGetAtSubscriptionResponse struct { // The remediation definition. Remediation }
RemediationsClientGetAtSubscriptionResponse contains the response from method RemediationsClient.GetAtSubscription.
type RemediationsClientListDeploymentsAtManagementGroupOptions ¶
type RemediationsClientListDeploymentsAtManagementGroupOptions struct { }
RemediationsClientListDeploymentsAtManagementGroupOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtManagementGroupPager method.
type RemediationsClientListDeploymentsAtManagementGroupResponse ¶
type RemediationsClientListDeploymentsAtManagementGroupResponse struct { // List of deployments for a remediation. RemediationDeploymentsListResult }
RemediationsClientListDeploymentsAtManagementGroupResponse contains the response from method RemediationsClient.NewListDeploymentsAtManagementGroupPager.
type RemediationsClientListDeploymentsAtResourceGroupOptions ¶
type RemediationsClientListDeploymentsAtResourceGroupOptions struct { }
RemediationsClientListDeploymentsAtResourceGroupOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtResourceGroupPager method.
type RemediationsClientListDeploymentsAtResourceGroupResponse ¶
type RemediationsClientListDeploymentsAtResourceGroupResponse struct { // List of deployments for a remediation. RemediationDeploymentsListResult }
RemediationsClientListDeploymentsAtResourceGroupResponse contains the response from method RemediationsClient.NewListDeploymentsAtResourceGroupPager.
type RemediationsClientListDeploymentsAtResourceOptions ¶
type RemediationsClientListDeploymentsAtResourceOptions struct { }
RemediationsClientListDeploymentsAtResourceOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtResourcePager method.
type RemediationsClientListDeploymentsAtResourceResponse ¶
type RemediationsClientListDeploymentsAtResourceResponse struct { // List of deployments for a remediation. RemediationDeploymentsListResult }
RemediationsClientListDeploymentsAtResourceResponse contains the response from method RemediationsClient.NewListDeploymentsAtResourcePager.
type RemediationsClientListDeploymentsAtSubscriptionOptions ¶
type RemediationsClientListDeploymentsAtSubscriptionOptions struct { }
RemediationsClientListDeploymentsAtSubscriptionOptions contains the optional parameters for the RemediationsClient.NewListDeploymentsAtSubscriptionPager method.
type RemediationsClientListDeploymentsAtSubscriptionResponse ¶
type RemediationsClientListDeploymentsAtSubscriptionResponse struct { // List of deployments for a remediation. RemediationDeploymentsListResult }
RemediationsClientListDeploymentsAtSubscriptionResponse contains the response from method RemediationsClient.NewListDeploymentsAtSubscriptionPager.
type RemediationsClientListForManagementGroupOptions ¶
type RemediationsClientListForManagementGroupOptions struct { }
RemediationsClientListForManagementGroupOptions contains the optional parameters for the RemediationsClient.NewListForManagementGroupPager method.
type RemediationsClientListForManagementGroupResponse ¶
type RemediationsClientListForManagementGroupResponse struct { // List of remediations. RemediationListResult }
RemediationsClientListForManagementGroupResponse contains the response from method RemediationsClient.NewListForManagementGroupPager.
type RemediationsClientListForResourceGroupOptions ¶
type RemediationsClientListForResourceGroupOptions struct { }
RemediationsClientListForResourceGroupOptions contains the optional parameters for the RemediationsClient.NewListForResourceGroupPager method.
type RemediationsClientListForResourceGroupResponse ¶
type RemediationsClientListForResourceGroupResponse struct { // List of remediations. RemediationListResult }
RemediationsClientListForResourceGroupResponse contains the response from method RemediationsClient.NewListForResourceGroupPager.
type RemediationsClientListForResourceOptions ¶
type RemediationsClientListForResourceOptions struct { }
RemediationsClientListForResourceOptions contains the optional parameters for the RemediationsClient.NewListForResourcePager method.
type RemediationsClientListForResourceResponse ¶
type RemediationsClientListForResourceResponse struct { // List of remediations. RemediationListResult }
RemediationsClientListForResourceResponse contains the response from method RemediationsClient.NewListForResourcePager.
type RemediationsClientListForSubscriptionOptions ¶
type RemediationsClientListForSubscriptionOptions struct { }
RemediationsClientListForSubscriptionOptions contains the optional parameters for the RemediationsClient.NewListForSubscriptionPager method.
type RemediationsClientListForSubscriptionResponse ¶
type RemediationsClientListForSubscriptionResponse struct { // List of remediations. RemediationListResult }
RemediationsClientListForSubscriptionResponse contains the response from method RemediationsClient.NewListForSubscriptionPager.
type Resource ¶
type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string // READ-ONLY; The name of the resource Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string }
Resource - Common fields that are returned in the response for all Azure Resource Manager resources
func (Resource) MarshalJSON ¶ added in v0.6.0
MarshalJSON implements the json.Marshaller interface for type Resource.
func (*Resource) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON implements the json.Unmarshaller interface for type Resource.
type ResourceDiscoveryMode ¶
type ResourceDiscoveryMode string
ResourceDiscoveryMode - The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified.
const ( // ResourceDiscoveryModeExistingNonCompliant - Remediate resources that are already known to be non-compliant. ResourceDiscoveryModeExistingNonCompliant ResourceDiscoveryMode = "ExistingNonCompliant" // ResourceDiscoveryModeReEvaluateCompliance - Re-evaluate the compliance state of resources and then remediate the resources // found to be non-compliant. ResourceDiscoveryModeReEvaluateCompliance ResourceDiscoveryMode = "ReEvaluateCompliance" )
func PossibleResourceDiscoveryModeValues ¶
func PossibleResourceDiscoveryModeValues() []ResourceDiscoveryMode
PossibleResourceDiscoveryModeValues returns the possible values for the ResourceDiscoveryMode const type.
type SlimPolicyMetadata ¶
type SlimPolicyMetadata struct { // Properties of the policy metadata. Properties *PolicyMetadataSlimProperties // READ-ONLY; The ID of the policy metadata. ID *string // READ-ONLY; The name of the policy metadata. Name *string // READ-ONLY; The type of the policy metadata. Type *string }
SlimPolicyMetadata - Slim version of policy metadata resource definition, excluding properties with large strings
func (SlimPolicyMetadata) MarshalJSON ¶ added in v0.6.0
func (s SlimPolicyMetadata) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type SlimPolicyMetadata.
func (*SlimPolicyMetadata) UnmarshalJSON ¶ added in v0.6.0
func (s *SlimPolicyMetadata) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type SlimPolicyMetadata.
type SummarizeResults ¶
type SummarizeResults struct { // OData context string; used by OData clients to resolve type information based on metadata. ODataContext *string // OData entity count; represents the number of summaries returned; always set to 1. ODataCount *int32 // Summarize action results. Value []*Summary }
SummarizeResults - Summarize action results.
func (SummarizeResults) MarshalJSON ¶
func (s SummarizeResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type SummarizeResults.
func (*SummarizeResults) UnmarshalJSON ¶ added in v0.6.0
func (s *SummarizeResults) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type SummarizeResults.
type Summary ¶
type Summary struct { // OData context string; used by OData clients to resolve type information based on metadata. ODataContext *string // OData entity ID; always set to null since summaries do not have an entity ID. ODataID *string // Policy assignments summary. PolicyAssignments []*PolicyAssignmentSummary // Compliance summary for all policy assignments. Results *SummaryResults }
Summary results.
func (Summary) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface for type Summary.
func (*Summary) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON implements the json.Unmarshaller interface for type Summary.
type SummaryResults ¶
type SummaryResults struct { // Number of non-compliant policies. NonCompliantPolicies *int32 // Number of non-compliant resources. NonCompliantResources *int32 // The policy artifact summary at this level. For query scope level, it represents policy assignment summary. For policy assignment // level, it represents policy definitions summary. PolicyDetails []*ComplianceDetail // The policy definition group summary at this level. PolicyGroupDetails []*ComplianceDetail // HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for the compliance summary. This // property will not be available by default in future API versions, but could // be queried explicitly. QueryResultsURI *string // The resources summary at this level. ResourceDetails []*ComplianceDetail }
SummaryResults - Compliance summary on a particular summary level.
func (SummaryResults) MarshalJSON ¶
func (s SummaryResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type SummaryResults.
func (*SummaryResults) UnmarshalJSON ¶ added in v0.6.0
func (s *SummaryResults) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type SummaryResults.
type SystemData ¶
type SystemData struct { // The timestamp of resource creation (UTC). CreatedAt *time.Time // The identity that created the resource. CreatedBy *string // The type of identity that created the resource. CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) LastModifiedAt *time.Time // The identity that last modified the resource. LastModifiedBy *string // The type of identity that last modified the resource. LastModifiedByType *CreatedByType }
SystemData - Metadata pertaining to creation and last modification of the resource.
func (SystemData) MarshalJSON ¶
func (s SystemData) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type SystemData.
func (*SystemData) UnmarshalJSON ¶
func (s *SystemData) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type SystemData.
type TrackedResourceModificationDetails ¶
type TrackedResourceModificationDetails struct { // READ-ONLY; The ID of the deployment that created or modified the tracked resource. DeploymentID *string // READ-ONLY; Timestamp of the deployment that created or modified the tracked resource. DeploymentTime *time.Time // READ-ONLY; The details of the policy that created or modified the tracked resource. PolicyDetails *PolicyDetails }
TrackedResourceModificationDetails - The details of the policy triggered deployment that created or modified the tracked resource.
func (TrackedResourceModificationDetails) MarshalJSON ¶
func (t TrackedResourceModificationDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type TrackedResourceModificationDetails.
func (*TrackedResourceModificationDetails) UnmarshalJSON ¶
func (t *TrackedResourceModificationDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResourceModificationDetails.
type TypedErrorInfo ¶
type TypedErrorInfo struct { // READ-ONLY; The scenario specific error details. Info any // READ-ONLY; The type of included error details. Type *string }
TypedErrorInfo - Scenario specific error details.
func (TypedErrorInfo) MarshalJSON ¶ added in v0.6.0
func (t TypedErrorInfo) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface for type TypedErrorInfo.
func (*TypedErrorInfo) UnmarshalJSON ¶ added in v0.6.0
func (t *TypedErrorInfo) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaller interface for type TypedErrorInfo.
Source Files ¶
- attestations_client.go
- build.go
- client_factory.go
- constants.go
- models.go
- models_serde.go
- operations_client.go
- options.go
- policyevents_client.go
- policymetadata_client.go
- policyrestrictions_client.go
- policystates_client.go
- policytrackedresources_client.go
- remediations_client.go
- response_types.go
- time_rfc3339.go