diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/CHANGELOG.md b/sdk/resourcemanager/policyinsights/armpolicyinsights/CHANGELOG.md index 3bea55775555..68b705b080ea 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/CHANGELOG.md +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/CHANGELOG.md @@ -1,5 +1,35 @@ # Release History +## 0.8.0 (2023-04-10) +### Breaking Changes + +- Type of `PolicyEvaluationResult.EvaluationDetails` has been changed from `*PolicyEvaluationDetails` to `*CheckRestrictionEvaluationDetails` + +### Features Added + +- New value `FieldRestrictionResultAudit` added to enum type `FieldRestrictionResult` +- New enum type `ComponentPolicyStatesResource` with values `ComponentPolicyStatesResourceLatest` +- New function `*ClientFactory.NewComponentPolicyStatesClient() *ComponentPolicyStatesClient` +- New function `NewComponentPolicyStatesClient(azcore.TokenCredential, *arm.ClientOptions) (*ComponentPolicyStatesClient, error)` +- New function `*ComponentPolicyStatesClient.ListQueryResultsForPolicyDefinition(context.Context, string, string, ComponentPolicyStatesResource, *ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionOptions) (ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse, error)` +- New function `*ComponentPolicyStatesClient.ListQueryResultsForResource(context.Context, string, ComponentPolicyStatesResource, *ComponentPolicyStatesClientListQueryResultsForResourceOptions) (ComponentPolicyStatesClientListQueryResultsForResourceResponse, error)` +- New function `*ComponentPolicyStatesClient.ListQueryResultsForResourceGroup(context.Context, string, string, ComponentPolicyStatesResource, *ComponentPolicyStatesClientListQueryResultsForResourceGroupOptions) (ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse, error)` +- New function `*ComponentPolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment(context.Context, string, string, string, ComponentPolicyStatesResource, *ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions) (ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse, error)` +- New function `*ComponentPolicyStatesClient.ListQueryResultsForSubscription(context.Context, string, ComponentPolicyStatesResource, *ComponentPolicyStatesClientListQueryResultsForSubscriptionOptions) (ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse, error)` +- New function `*ComponentPolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment(context.Context, string, string, ComponentPolicyStatesResource, *ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions) (ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse, error)` +- New struct `CheckRestrictionEvaluationDetails` +- New struct `ComponentExpressionEvaluationDetails` +- New struct `ComponentPolicyEvaluationDetails` +- New struct `ComponentPolicyState` +- New struct `ComponentPolicyStatesQueryResults` +- New struct `PolicyEffectDetails` +- New field `IncludeAuditEffect` in struct `CheckRestrictionsRequest` +- New field `PolicyEffect` in struct `FieldRestriction` +- New field `Reason` in struct `FieldRestriction` +- New field `IsDataAction` in struct `Operation` +- New field `EffectDetails` in struct `PolicyEvaluationResult` + + ## 0.7.0 (2023-03-31) ### Features Added diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/attestations_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/attestations_client_example_test.go deleted file mode 100644 index 979e3234ed47..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/attestations_client_example_test.go +++ /dev/null @@ -1,969 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExampleAttestationsClient_NewListForSubscriptionPager_listAttestationsAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleAttestationsClient_NewListForSubscriptionPager_listAttestationsAtSubscriptionScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleAttestationsClient_BeginCreateOrUpdateAtSubscription_createAttestationAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_BeginCreateOrUpdateAtSubscription_createAttestationAtSubscriptionScopeWithAllProperties() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_GetAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_DeleteAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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) - } -} - -// 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 -func ExampleAttestationsClient_NewListForResourceGroupPager_listAttestationsAtResourceGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleAttestationsClient_NewListForResourceGroupPager_listAttestationsAtResourceGroupScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleAttestationsClient_BeginCreateOrUpdateAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_GetAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_DeleteAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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) - } -} - -// 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 -func ExampleAttestationsClient_NewListForResourcePager_listAttestationsAtIndividualResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleAttestationsClient_NewListForResourcePager_listAttestationsAtIndividualResourceScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleAttestationsClient_BeginCreateOrUpdateAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_GetAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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:00Z"); return t}()), - // LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleAttestationsClient_DeleteAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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) - } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/autorest.md b/sdk/resourcemanager/policyinsights/armpolicyinsights/autorest.md index 86ad23cc0825..7cc6d6e13c92 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/autorest.md +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/policyinsights/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/policyinsights/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.7.0 +module-version: 0.8.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/client_factory.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/client_factory.go index de9f6ce05733..13c069fcbdc9 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/client_factory.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/client_factory.go @@ -58,11 +58,6 @@ func (c *ClientFactory) NewPolicyStatesClient() *PolicyStatesClient { return subClient } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient -} - func (c *ClientFactory) NewPolicyMetadataClient() *PolicyMetadataClient { subClient, _ := NewPolicyMetadataClient(c.credential, c.options) return subClient @@ -73,6 +68,16 @@ func (c *ClientFactory) NewPolicyRestrictionsClient() *PolicyRestrictionsClient return subClient } +func (c *ClientFactory) NewComponentPolicyStatesClient() *ComponentPolicyStatesClient { + subClient, _ := NewComponentPolicyStatesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewAttestationsClient() *AttestationsClient { subClient, _ := NewAttestationsClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/componentpolicystates_client.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/componentpolicystates_client.go new file mode 100644 index 000000000000..f7b5218aac86 --- /dev/null +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/componentpolicystates_client.go @@ -0,0 +1,530 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armpolicyinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// ComponentPolicyStatesClient contains the methods for the ComponentPolicyStates group. +// Don't use this type directly, use NewComponentPolicyStatesClient() instead. +type ComponentPolicyStatesClient struct { + internal *arm.Client +} + +// NewComponentPolicyStatesClient creates a new instance of ComponentPolicyStatesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewComponentPolicyStatesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentPolicyStatesClient, error) { + cl, err := arm.NewClient(moduleName+".ComponentPolicyStatesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ComponentPolicyStatesClient{ + internal: cl, + } + return client, nil +} + +// ListQueryResultsForPolicyDefinition - Queries component policy states for the subscription level policy definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-04-01 +// - subscriptionID - Microsoft Azure subscription ID. +// - policyDefinitionName - Policy definition name. +// - componentPolicyStatesResource - The virtual resource under ComponentPolicyStates resource type. In a given time range, +// 'latest' represents the latest component policy state(s). +// - options - ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionOptions contains the optional parameters for the +// ComponentPolicyStatesClient.ListQueryResultsForPolicyDefinition method. +func (client *ComponentPolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context.Context, subscriptionID string, policyDefinitionName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionOptions) (ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse, error) { + req, err := client.listQueryResultsForPolicyDefinitionCreateRequest(ctx, subscriptionID, policyDefinitionName, componentPolicyStatesResource, options) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse{}, runtime.NewResponseError(resp) + } + return client.listQueryResultsForPolicyDefinitionHandleResponse(resp) +} + +// listQueryResultsForPolicyDefinitionCreateRequest creates the ListQueryResultsForPolicyDefinition request. +func (client *ComponentPolicyStatesClient) listQueryResultsForPolicyDefinitionCreateRequest(ctx context.Context, subscriptionID string, policyDefinitionName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape("Microsoft.Authorization")) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if componentPolicyStatesResource == "" { + return nil, errors.New("parameter componentPolicyStatesResource cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{componentPolicyStatesResource}", url.PathEscape(string(componentPolicyStatesResource))) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("$orderby", *options.OrderBy) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.From != nil { + reqQP.Set("$from", options.From.Format(time.RFC3339Nano)) + } + if options != nil && options.To != nil { + reqQP.Set("$to", options.To.Format(time.RFC3339Nano)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQueryResultsForPolicyDefinitionHandleResponse handles the ListQueryResultsForPolicyDefinition response. +func (client *ComponentPolicyStatesClient) listQueryResultsForPolicyDefinitionHandleResponse(resp *http.Response) (ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse, error) { + result := ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentPolicyStatesQueryResults); err != nil { + return ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse{}, err + } + return result, nil +} + +// ListQueryResultsForResource - Queries component policy states for the resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-04-01 +// - resourceID - Resource ID. +// - componentPolicyStatesResource - The virtual resource under ComponentPolicyStates resource type. In a given time range, +// 'latest' represents the latest component policy state(s). +// - options - ComponentPolicyStatesClientListQueryResultsForResourceOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForResource +// method. +func (client *ComponentPolicyStatesClient) ListQueryResultsForResource(ctx context.Context, resourceID string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForResourceOptions) (ComponentPolicyStatesClientListQueryResultsForResourceResponse, error) { + req, err := client.listQueryResultsForResourceCreateRequest(ctx, resourceID, componentPolicyStatesResource, options) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ComponentPolicyStatesClientListQueryResultsForResourceResponse{}, runtime.NewResponseError(resp) + } + return client.listQueryResultsForResourceHandleResponse(resp) +} + +// listQueryResultsForResourceCreateRequest creates the ListQueryResultsForResource request. +func (client *ComponentPolicyStatesClient) listQueryResultsForResourceCreateRequest(ctx context.Context, resourceID string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForResourceOptions) (*policy.Request, error) { + urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) + if componentPolicyStatesResource == "" { + return nil, errors.New("parameter componentPolicyStatesResource cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{componentPolicyStatesResource}", url.PathEscape(string(componentPolicyStatesResource))) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("$orderby", *options.OrderBy) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.From != nil { + reqQP.Set("$from", options.From.Format(time.RFC3339Nano)) + } + if options != nil && options.To != nil { + reqQP.Set("$to", options.To.Format(time.RFC3339Nano)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQueryResultsForResourceHandleResponse handles the ListQueryResultsForResource response. +func (client *ComponentPolicyStatesClient) listQueryResultsForResourceHandleResponse(resp *http.Response) (ComponentPolicyStatesClientListQueryResultsForResourceResponse, error) { + result := ComponentPolicyStatesClientListQueryResultsForResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentPolicyStatesQueryResults); err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceResponse{}, err + } + return result, nil +} + +// ListQueryResultsForResourceGroup - Queries component policy states under resource group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-04-01 +// - subscriptionID - Microsoft Azure subscription ID. +// - resourceGroupName - Resource group name. +// - componentPolicyStatesResource - The virtual resource under ComponentPolicyStates resource type. In a given time range, +// 'latest' represents the latest component policy state(s). +// - options - ComponentPolicyStatesClientListQueryResultsForResourceGroupOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForResourceGroup +// method. +func (client *ComponentPolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForResourceGroupOptions) (ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse, error) { + req, err := client.listQueryResultsForResourceGroupCreateRequest(ctx, subscriptionID, resourceGroupName, componentPolicyStatesResource, options) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listQueryResultsForResourceGroupHandleResponse(resp) +} + +// listQueryResultsForResourceGroupCreateRequest creates the ListQueryResultsForResourceGroup request. +func (client *ComponentPolicyStatesClient) listQueryResultsForResourceGroupCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if componentPolicyStatesResource == "" { + return nil, errors.New("parameter componentPolicyStatesResource cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{componentPolicyStatesResource}", url.PathEscape(string(componentPolicyStatesResource))) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("$orderby", *options.OrderBy) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.From != nil { + reqQP.Set("$from", options.From.Format(time.RFC3339Nano)) + } + if options != nil && options.To != nil { + reqQP.Set("$to", options.To.Format(time.RFC3339Nano)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQueryResultsForResourceGroupHandleResponse handles the ListQueryResultsForResourceGroup response. +func (client *ComponentPolicyStatesClient) listQueryResultsForResourceGroupHandleResponse(resp *http.Response) (ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse, error) { + result := ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentPolicyStatesQueryResults); err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse{}, err + } + return result, nil +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignment - Queries component policy states for the resource group level policy +// assignment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-04-01 +// - subscriptionID - Microsoft Azure subscription ID. +// - resourceGroupName - Resource group name. +// - policyAssignmentName - Policy assignment name. +// - componentPolicyStatesResource - The virtual resource under ComponentPolicyStates resource type. In a given time range, +// 'latest' represents the latest component policy state(s). +// - options - ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions contains the optional +// parameters for the ComponentPolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment method. +func (client *ComponentPolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions) (ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse, error) { + req, err := client.listQueryResultsForResourceGroupLevelPolicyAssignmentCreateRequest(ctx, subscriptionID, resourceGroupName, policyAssignmentName, componentPolicyStatesResource, options) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{}, runtime.NewResponseError(resp) + } + return client.listQueryResultsForResourceGroupLevelPolicyAssignmentHandleResponse(resp) +} + +// listQueryResultsForResourceGroupLevelPolicyAssignmentCreateRequest creates the ListQueryResultsForResourceGroupLevelPolicyAssignment request. +func (client *ComponentPolicyStatesClient) listQueryResultsForResourceGroupLevelPolicyAssignmentCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape("Microsoft.Authorization")) + if policyAssignmentName == "" { + return nil, errors.New("parameter policyAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentName}", url.PathEscape(policyAssignmentName)) + if componentPolicyStatesResource == "" { + return nil, errors.New("parameter componentPolicyStatesResource cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{componentPolicyStatesResource}", url.PathEscape(string(componentPolicyStatesResource))) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("$orderby", *options.OrderBy) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.From != nil { + reqQP.Set("$from", options.From.Format(time.RFC3339Nano)) + } + if options != nil && options.To != nil { + reqQP.Set("$to", options.To.Format(time.RFC3339Nano)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQueryResultsForResourceGroupLevelPolicyAssignmentHandleResponse handles the ListQueryResultsForResourceGroupLevelPolicyAssignment response. +func (client *ComponentPolicyStatesClient) listQueryResultsForResourceGroupLevelPolicyAssignmentHandleResponse(resp *http.Response) (ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse, error) { + result := ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentPolicyStatesQueryResults); err != nil { + return ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{}, err + } + return result, nil +} + +// ListQueryResultsForSubscription - Queries component policy states under subscription scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-04-01 +// - subscriptionID - Microsoft Azure subscription ID. +// - componentPolicyStatesResource - The virtual resource under ComponentPolicyStates resource type. In a given time range, +// 'latest' represents the latest component policy state(s). +// - options - ComponentPolicyStatesClientListQueryResultsForSubscriptionOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForSubscription +// method. +func (client *ComponentPolicyStatesClient) ListQueryResultsForSubscription(ctx context.Context, subscriptionID string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForSubscriptionOptions) (ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse, error) { + req, err := client.listQueryResultsForSubscriptionCreateRequest(ctx, subscriptionID, componentPolicyStatesResource, options) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listQueryResultsForSubscriptionHandleResponse(resp) +} + +// listQueryResultsForSubscriptionCreateRequest creates the ListQueryResultsForSubscription request. +func (client *ComponentPolicyStatesClient) listQueryResultsForSubscriptionCreateRequest(ctx context.Context, subscriptionID string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if componentPolicyStatesResource == "" { + return nil, errors.New("parameter componentPolicyStatesResource cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{componentPolicyStatesResource}", url.PathEscape(string(componentPolicyStatesResource))) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("$orderby", *options.OrderBy) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.From != nil { + reqQP.Set("$from", options.From.Format(time.RFC3339Nano)) + } + if options != nil && options.To != nil { + reqQP.Set("$to", options.To.Format(time.RFC3339Nano)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQueryResultsForSubscriptionHandleResponse handles the ListQueryResultsForSubscription response. +func (client *ComponentPolicyStatesClient) listQueryResultsForSubscriptionHandleResponse(resp *http.Response) (ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse, error) { + result := ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentPolicyStatesQueryResults); err != nil { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse{}, err + } + return result, nil +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignment - Queries component policy states for the subscription level policy +// assignment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-04-01 +// - subscriptionID - Microsoft Azure subscription ID. +// - policyAssignmentName - Policy assignment name. +// - componentPolicyStatesResource - The virtual resource under ComponentPolicyStates resource type. In a given time range, +// 'latest' represents the latest component policy state(s). +// - options - ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions contains the optional +// parameters for the ComponentPolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment method. +func (client *ComponentPolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, subscriptionID string, policyAssignmentName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions) (ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse, error) { + req, err := client.listQueryResultsForSubscriptionLevelPolicyAssignmentCreateRequest(ctx, subscriptionID, policyAssignmentName, componentPolicyStatesResource, options) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{}, runtime.NewResponseError(resp) + } + return client.listQueryResultsForSubscriptionLevelPolicyAssignmentHandleResponse(resp) +} + +// listQueryResultsForSubscriptionLevelPolicyAssignmentCreateRequest creates the ListQueryResultsForSubscriptionLevelPolicyAssignment request. +func (client *ComponentPolicyStatesClient) listQueryResultsForSubscriptionLevelPolicyAssignmentCreateRequest(ctx context.Context, subscriptionID string, policyAssignmentName string, componentPolicyStatesResource ComponentPolicyStatesResource, options *ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape("Microsoft.Authorization")) + if policyAssignmentName == "" { + return nil, errors.New("parameter policyAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentName}", url.PathEscape(policyAssignmentName)) + if componentPolicyStatesResource == "" { + return nil, errors.New("parameter componentPolicyStatesResource cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{componentPolicyStatesResource}", url.PathEscape(string(componentPolicyStatesResource))) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.OrderBy != nil { + reqQP.Set("$orderby", *options.OrderBy) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.From != nil { + reqQP.Set("$from", options.From.Format(time.RFC3339Nano)) + } + if options != nil && options.To != nil { + reqQP.Set("$to", options.To.Format(time.RFC3339Nano)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQueryResultsForSubscriptionLevelPolicyAssignmentHandleResponse handles the ListQueryResultsForSubscriptionLevelPolicyAssignment response. +func (client *ComponentPolicyStatesClient) listQueryResultsForSubscriptionLevelPolicyAssignmentHandleResponse(resp *http.Response) (ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse, error) { + result := ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentPolicyStatesQueryResults); err != nil { + return ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/constants.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/constants.go index e6ccc9f0ff5f..079ed94cf14b 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/constants.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/constants.go @@ -11,7 +11,7 @@ package armpolicyinsights const ( moduleName = "armpolicyinsights" - moduleVersion = "v0.7.0" + moduleVersion = "v0.8.0" ) // ComplianceState - The compliance state that should be set on the resource. @@ -35,6 +35,19 @@ func PossibleComplianceStateValues() []ComplianceState { } } +type ComponentPolicyStatesResource string + +const ( + ComponentPolicyStatesResourceLatest ComponentPolicyStatesResource = "latest" +) + +// PossibleComponentPolicyStatesResourceValues returns the possible values for the ComponentPolicyStatesResource const type. +func PossibleComponentPolicyStatesResourceValues() []ComponentPolicyStatesResource { + return []ComponentPolicyStatesResource{ + ComponentPolicyStatesResourceLatest, + } +} + // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -59,6 +72,8 @@ func PossibleCreatedByTypeValues() []CreatedByType { type FieldRestrictionResult string const ( + // FieldRestrictionResultAudit - The field and/or values will be audited by policy. + FieldRestrictionResultAudit FieldRestrictionResult = "Audit" // FieldRestrictionResultDeny - The field and/or values will be denied by policy. FieldRestrictionResultDeny FieldRestrictionResult = "Deny" // FieldRestrictionResultRemoved - The field will be removed by policy. @@ -70,6 +85,7 @@ const ( // PossibleFieldRestrictionResultValues returns the possible values for the FieldRestrictionResult const type. func PossibleFieldRestrictionResultValues() []FieldRestrictionResult { return []FieldRestrictionResult{ + FieldRestrictionResultAudit, FieldRestrictionResultDeny, FieldRestrictionResultRemoved, FieldRestrictionResultRequired, diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/go.mod b/sdk/resourcemanager/policyinsights/armpolicyinsights/go.mod index 6f9ad56d94aa..512f51ac4256 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/go.mod +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armp go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/go.sum b/sdk/resourcemanager/policyinsights/armpolicyinsights/go.sum index 8ba445a8c4da..b6bd7eaad1ba 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/go.sum +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/go.sum @@ -1,31 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/models.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/models.go index c9d990d35ae1..8370ea325baa 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/models.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/models.go @@ -170,11 +170,26 @@ type CheckManagementGroupRestrictionsRequest struct { ResourceDetails *CheckRestrictionsResourceDetails `json:"resourceDetails,omitempty"` } +// CheckRestrictionEvaluationDetails - Policy evaluation details. +type CheckRestrictionEvaluationDetails struct { + // Details of the evaluated expressions. + EvaluatedExpressions []*ExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` + + // Evaluation details of IfNotExists effect. + IfNotExistsDetails *IfNotExistsEvaluationDetails `json:"ifNotExistsDetails,omitempty"` + + // READ-ONLY; The reason for the evaluation result. + Reason *string `json:"reason,omitempty" azure:"ro"` +} + // CheckRestrictionsRequest - The check policy restrictions parameters describing the resource that is being evaluated. type CheckRestrictionsRequest struct { // REQUIRED; The information about the resource that will be evaluated. ResourceDetails *CheckRestrictionsResourceDetails `json:"resourceDetails,omitempty"` + // Whether to include policies with the 'audit' effect in the results. Defaults to false. + IncludeAuditEffect *bool `json:"includeAuditEffect,omitempty"` + // The list of fields and values that should be evaluated for potential restrictions. PendingFields []*PendingField `json:"pendingFields,omitempty"` } @@ -245,6 +260,293 @@ type ComponentEventDetails struct { Type *string `json:"type,omitempty"` } +// ComponentExpressionEvaluationDetails - Evaluation details of policy language expressions. +type ComponentExpressionEvaluationDetails struct { + // Evaluation result. + Result *string `json:"result,omitempty"` + + // READ-ONLY; Expression evaluated. + Expression *string `json:"expression,omitempty" azure:"ro"` + + // READ-ONLY; The kind of expression that was evaluated. + ExpressionKind *string `json:"expressionKind,omitempty" azure:"ro"` + + // READ-ONLY; Value of the expression. + ExpressionValue any `json:"expressionValue,omitempty" azure:"ro"` + + // READ-ONLY; Operator to compare the expression value and the target value. + Operator *string `json:"operator,omitempty" azure:"ro"` + + // READ-ONLY; Property path if the expression is a field or an alias. + Path *string `json:"path,omitempty" azure:"ro"` + + // READ-ONLY; Target value to be compared with the expression value. + TargetValue any `json:"targetValue,omitempty" azure:"ro"` +} + +// ComponentPolicyEvaluationDetails - Policy evaluation details. +type ComponentPolicyEvaluationDetails struct { + // Additional textual reason for the evaluation outcome. + Reason *string `json:"reason,omitempty"` + + // READ-ONLY; Details of the evaluated expressions. + EvaluatedExpressions []*ComponentExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty" azure:"ro"` +} + +// ComponentPolicyState - Component Policy State record. +type ComponentPolicyState struct { + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]any + + // Policy evaluation details. This is only included in the response if the request contains $expand=PolicyEvaluationDetails. + PolicyEvaluationDetails *ComponentPolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` + + // READ-ONLY; Compliance state of the resource. + ComplianceState *string `json:"complianceState,omitempty" azure:"ro"` + + // READ-ONLY; Component Id. + ComponentID *string `json:"componentId,omitempty" azure:"ro"` + + // READ-ONLY; Component name. + ComponentName *string `json:"componentName,omitempty" azure:"ro"` + + // READ-ONLY; Component type. + ComponentType *string `json:"componentType,omitempty" azure:"ro"` + + // READ-ONLY; OData context string; used by OData clients to resolve type information based on metadata. + ODataContext *string `json:"@odata.context,omitempty" azure:"ro"` + + // READ-ONLY; OData entity ID; always set to null since component policy state records do not have an entity ID. + ODataID *string `json:"@odata.id,omitempty" azure:"ro"` + + // READ-ONLY; Policy assignment ID. + PolicyAssignmentID *string `json:"policyAssignmentId,omitempty" azure:"ro"` + + // READ-ONLY; Policy assignment name. + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty" azure:"ro"` + + // READ-ONLY; Policy assignment owner. + PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty" azure:"ro"` + + // READ-ONLY; Policy assignment parameters. + PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty" azure:"ro"` + + // READ-ONLY; Policy assignment scope. + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty" azure:"ro"` + + // READ-ONLY; Evaluated policy assignment version. + PolicyAssignmentVersion *string `json:"policyAssignmentVersion,omitempty" azure:"ro"` + + // READ-ONLY; Policy definition action, i.e. effect. + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty" azure:"ro"` + + // READ-ONLY; Policy definition category. + PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty" azure:"ro"` + + // READ-ONLY; Policy definition group names. + PolicyDefinitionGroupNames []*string `json:"policyDefinitionGroupNames,omitempty" azure:"ro"` + + // READ-ONLY; Policy definition ID. + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty" azure:"ro"` + + // READ-ONLY; Policy definition name. + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty" azure:"ro"` + + // READ-ONLY; Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. + PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty" azure:"ro"` + + // READ-ONLY; Evaluated policy definition version. + PolicyDefinitionVersion *string `json:"policyDefinitionVersion,omitempty" azure:"ro"` + + // READ-ONLY; Policy set definition category, if the policy assignment is for a policy set. + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty" azure:"ro"` + + // READ-ONLY; Policy set definition ID, if the policy assignment is for a policy set. + PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty" azure:"ro"` + + // READ-ONLY; Policy set definition name, if the policy assignment is for a policy set. + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty" azure:"ro"` + + // READ-ONLY; Policy set definition owner, if the policy assignment is for a policy set. + PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty" azure:"ro"` + + // READ-ONLY; Policy set definition parameters, if the policy assignment is for a policy set. + PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty" azure:"ro"` + + // READ-ONLY; Evaluated policy set definition version. + PolicySetDefinitionVersion *string `json:"policySetDefinitionVersion,omitempty" azure:"ro"` + + // READ-ONLY; Resource group name. + ResourceGroup *string `json:"resourceGroup,omitempty" azure:"ro"` + + // READ-ONLY; Resource ID. + ResourceID *string `json:"resourceId,omitempty" azure:"ro"` + + // READ-ONLY; Resource location. + ResourceLocation *string `json:"resourceLocation,omitempty" azure:"ro"` + + // READ-ONLY; Resource type. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; Subscription ID. + SubscriptionID *string `json:"subscriptionId,omitempty" azure:"ro"` + + // READ-ONLY; Timestamp for the component policy state record. + Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` +} + +// ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForPolicyDefinition +// method. +type ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionOptions struct { + // OData apply expression for aggregations. + Apply *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 + // 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 +} + +// ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions contains the optional parameters +// for the ComponentPolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment method. +type ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentOptions struct { + // OData apply expression for aggregations. + Apply *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 + // 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 +} + +// ComponentPolicyStatesClientListQueryResultsForResourceGroupOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForResourceGroup +// method. +type ComponentPolicyStatesClientListQueryResultsForResourceGroupOptions struct { + // OData apply expression for aggregations. + Apply *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 + // 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 +} + +// ComponentPolicyStatesClientListQueryResultsForResourceOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForResource +// method. +type ComponentPolicyStatesClientListQueryResultsForResourceOptions struct { + // OData apply expression for aggregations. + Apply *string + // The $expand query parameter. + 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 + // 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 +} + +// ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions contains the optional parameters +// for the ComponentPolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment method. +type ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentOptions struct { + // OData apply expression for aggregations. + Apply *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 + // 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 +} + +// ComponentPolicyStatesClientListQueryResultsForSubscriptionOptions contains the optional parameters for the ComponentPolicyStatesClient.ListQueryResultsForSubscription +// method. +type ComponentPolicyStatesClientListQueryResultsForSubscriptionOptions struct { + // OData apply expression for aggregations. + Apply *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 + // 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 +} + +// ComponentPolicyStatesQueryResults - Query results. +type ComponentPolicyStatesQueryResults struct { + // OData context string; used by OData clients to resolve type information based on metadata. + ODataContext *string `json:"@odata.context,omitempty"` + + // OData entity count; represents the number of policy state records returned. + ODataCount *int32 `json:"@odata.count,omitempty"` + + // Query results. + Value []*ComponentPolicyState `json:"value,omitempty"` +} + // ComponentStateDetails - Component state details. type ComponentStateDetails struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. @@ -370,6 +672,12 @@ type FieldRestriction struct { // READ-ONLY; The details of the policy that is causing the field restriction. Policy *PolicyReference `json:"policy,omitempty" azure:"ro"` + // READ-ONLY; The effect of the policy that is causing the field restriction. http://aka.ms/policyeffects + PolicyEffect *string `json:"policyEffect,omitempty" azure:"ro"` + + // READ-ONLY; The reason for the restriction. + Reason *string `json:"reason,omitempty" azure:"ro"` + // READ-ONLY; The type of restriction that is imposed on the field. Result *FieldRestrictionResult `json:"result,omitempty" azure:"ro"` @@ -400,6 +708,9 @@ type Operation struct { // Display metadata associated with the operation. Display *OperationDisplay `json:"display,omitempty"` + // Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Operation name. Name *string `json:"name,omitempty"` } @@ -499,6 +810,12 @@ type PolicyDetails struct { PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty" azure:"ro"` } +// PolicyEffectDetails - The details of the effect that was applied to the resource. +type PolicyEffectDetails struct { + // READ-ONLY; The effect that was applied to the resource. http://aka.ms/policyeffects + PolicyEffect *string `json:"policyEffect,omitempty" azure:"ro"` +} + // PolicyEvaluationDetails - Policy evaluation details. type PolicyEvaluationDetails struct { // Details of the evaluated expressions. @@ -510,8 +827,11 @@ type PolicyEvaluationDetails struct { // PolicyEvaluationResult - The result of a non-compliant policy evaluation against the given resource content. type PolicyEvaluationResult struct { + // READ-ONLY; The details of the effect that was applied to the resource. + EffectDetails *PolicyEffectDetails `json:"effectDetails,omitempty" azure:"ro"` + // READ-ONLY; The detailed results of the policy expressions and values that were evaluated. - EvaluationDetails *PolicyEvaluationDetails `json:"evaluationDetails,omitempty" azure:"ro"` + EvaluationDetails *CheckRestrictionEvaluationDetails `json:"evaluationDetails,omitempty" azure:"ro"` // 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. @@ -1249,7 +1569,8 @@ type RemediationProperties struct { // READ-ONLY; The time at which the remediation was last updated. LastUpdatedOn *time.Time `json:"lastUpdatedOn,omitempty" azure:"ro"` - // READ-ONLY; The status of the remediation. + // READ-ONLY; The status of the remediation. This refers to the entire remediation task, not individual deployments. Allowed + // values are Evaluating, Canceled, Cancelling, Failed, Complete, or Succeeded. ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` // READ-ONLY; The remediation status message. Provides additional details regarding the state of the remediation. diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/models_serde.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/models_serde.go index addd31de9e2b..df2e7a6c7aff 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/models_serde.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/models_serde.go @@ -219,9 +219,45 @@ func (c *CheckManagementGroupRestrictionsRequest) UnmarshalJSON(data []byte) err return nil } +// MarshalJSON implements the json.Marshaller interface for type CheckRestrictionEvaluationDetails. +func (c CheckRestrictionEvaluationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "evaluatedExpressions", c.EvaluatedExpressions) + populate(objectMap, "ifNotExistsDetails", c.IfNotExistsDetails) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckRestrictionEvaluationDetails. +func (c *CheckRestrictionEvaluationDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "evaluatedExpressions": + err = unpopulate(val, "EvaluatedExpressions", &c.EvaluatedExpressions) + delete(rawMsg, key) + case "ifNotExistsDetails": + err = unpopulate(val, "IfNotExistsDetails", &c.IfNotExistsDetails) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CheckRestrictionsRequest. func (c CheckRestrictionsRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "includeAuditEffect", c.IncludeAuditEffect) populate(objectMap, "pendingFields", c.PendingFields) populate(objectMap, "resourceDetails", c.ResourceDetails) return json.Marshal(objectMap) @@ -236,6 +272,9 @@ func (c *CheckRestrictionsRequest) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "includeAuditEffect": + err = unpopulate(val, "IncludeAuditEffect", &c.IncludeAuditEffect) + delete(rawMsg, key) case "pendingFields": err = unpopulate(val, "PendingFields", &c.PendingFields) delete(rawMsg, key) @@ -440,6 +479,289 @@ func (c *ComponentEventDetails) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ComponentExpressionEvaluationDetails. +func (c ComponentExpressionEvaluationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expression", c.Expression) + populate(objectMap, "expressionKind", c.ExpressionKind) + populate(objectMap, "expressionValue", &c.ExpressionValue) + populate(objectMap, "operator", c.Operator) + populate(objectMap, "path", c.Path) + populate(objectMap, "result", c.Result) + populate(objectMap, "targetValue", &c.TargetValue) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentExpressionEvaluationDetails. +func (c *ComponentExpressionEvaluationDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expression": + err = unpopulate(val, "Expression", &c.Expression) + delete(rawMsg, key) + case "expressionKind": + err = unpopulate(val, "ExpressionKind", &c.ExpressionKind) + delete(rawMsg, key) + case "expressionValue": + err = unpopulate(val, "ExpressionValue", &c.ExpressionValue) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &c.Operator) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &c.Path) + delete(rawMsg, key) + case "result": + err = unpopulate(val, "Result", &c.Result) + delete(rawMsg, key) + case "targetValue": + err = unpopulate(val, "TargetValue", &c.TargetValue) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ComponentPolicyEvaluationDetails. +func (c ComponentPolicyEvaluationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "evaluatedExpressions", c.EvaluatedExpressions) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentPolicyEvaluationDetails. +func (c *ComponentPolicyEvaluationDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "evaluatedExpressions": + err = unpopulate(val, "EvaluatedExpressions", &c.EvaluatedExpressions) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ComponentPolicyState. +func (c ComponentPolicyState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceState", c.ComplianceState) + populate(objectMap, "componentId", c.ComponentID) + populate(objectMap, "componentName", c.ComponentName) + populate(objectMap, "componentType", c.ComponentType) + populate(objectMap, "@odata.context", c.ODataContext) + populate(objectMap, "@odata.id", c.ODataID) + populate(objectMap, "policyAssignmentId", c.PolicyAssignmentID) + populate(objectMap, "policyAssignmentName", c.PolicyAssignmentName) + populate(objectMap, "policyAssignmentOwner", c.PolicyAssignmentOwner) + populate(objectMap, "policyAssignmentParameters", c.PolicyAssignmentParameters) + populate(objectMap, "policyAssignmentScope", c.PolicyAssignmentScope) + populate(objectMap, "policyAssignmentVersion", c.PolicyAssignmentVersion) + populate(objectMap, "policyDefinitionAction", c.PolicyDefinitionAction) + populate(objectMap, "policyDefinitionCategory", c.PolicyDefinitionCategory) + populate(objectMap, "policyDefinitionGroupNames", c.PolicyDefinitionGroupNames) + populate(objectMap, "policyDefinitionId", c.PolicyDefinitionID) + populate(objectMap, "policyDefinitionName", c.PolicyDefinitionName) + populate(objectMap, "policyDefinitionReferenceId", c.PolicyDefinitionReferenceID) + populate(objectMap, "policyDefinitionVersion", c.PolicyDefinitionVersion) + populate(objectMap, "policyEvaluationDetails", c.PolicyEvaluationDetails) + populate(objectMap, "policySetDefinitionCategory", c.PolicySetDefinitionCategory) + populate(objectMap, "policySetDefinitionId", c.PolicySetDefinitionID) + populate(objectMap, "policySetDefinitionName", c.PolicySetDefinitionName) + populate(objectMap, "policySetDefinitionOwner", c.PolicySetDefinitionOwner) + populate(objectMap, "policySetDefinitionParameters", c.PolicySetDefinitionParameters) + populate(objectMap, "policySetDefinitionVersion", c.PolicySetDefinitionVersion) + populate(objectMap, "resourceGroup", c.ResourceGroup) + populate(objectMap, "resourceId", c.ResourceID) + populate(objectMap, "resourceLocation", c.ResourceLocation) + populate(objectMap, "resourceType", c.ResourceType) + populate(objectMap, "subscriptionId", c.SubscriptionID) + populateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + if c.AdditionalProperties != nil { + for key, val := range c.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentPolicyState. +func (c *ComponentPolicyState) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceState": + err = unpopulate(val, "ComplianceState", &c.ComplianceState) + delete(rawMsg, key) + case "componentId": + err = unpopulate(val, "ComponentID", &c.ComponentID) + delete(rawMsg, key) + case "componentName": + err = unpopulate(val, "ComponentName", &c.ComponentName) + delete(rawMsg, key) + case "componentType": + err = unpopulate(val, "ComponentType", &c.ComponentType) + delete(rawMsg, key) + case "@odata.context": + err = unpopulate(val, "ODataContext", &c.ODataContext) + delete(rawMsg, key) + case "@odata.id": + err = unpopulate(val, "ODataID", &c.ODataID) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &c.PolicyAssignmentID) + delete(rawMsg, key) + case "policyAssignmentName": + err = unpopulate(val, "PolicyAssignmentName", &c.PolicyAssignmentName) + delete(rawMsg, key) + case "policyAssignmentOwner": + err = unpopulate(val, "PolicyAssignmentOwner", &c.PolicyAssignmentOwner) + delete(rawMsg, key) + case "policyAssignmentParameters": + err = unpopulate(val, "PolicyAssignmentParameters", &c.PolicyAssignmentParameters) + delete(rawMsg, key) + case "policyAssignmentScope": + err = unpopulate(val, "PolicyAssignmentScope", &c.PolicyAssignmentScope) + delete(rawMsg, key) + case "policyAssignmentVersion": + err = unpopulate(val, "PolicyAssignmentVersion", &c.PolicyAssignmentVersion) + delete(rawMsg, key) + case "policyDefinitionAction": + err = unpopulate(val, "PolicyDefinitionAction", &c.PolicyDefinitionAction) + delete(rawMsg, key) + case "policyDefinitionCategory": + err = unpopulate(val, "PolicyDefinitionCategory", &c.PolicyDefinitionCategory) + delete(rawMsg, key) + case "policyDefinitionGroupNames": + err = unpopulate(val, "PolicyDefinitionGroupNames", &c.PolicyDefinitionGroupNames) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &c.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionName": + err = unpopulate(val, "PolicyDefinitionName", &c.PolicyDefinitionName) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &c.PolicyDefinitionReferenceID) + delete(rawMsg, key) + case "policyDefinitionVersion": + err = unpopulate(val, "PolicyDefinitionVersion", &c.PolicyDefinitionVersion) + delete(rawMsg, key) + case "policyEvaluationDetails": + err = unpopulate(val, "PolicyEvaluationDetails", &c.PolicyEvaluationDetails) + delete(rawMsg, key) + case "policySetDefinitionCategory": + err = unpopulate(val, "PolicySetDefinitionCategory", &c.PolicySetDefinitionCategory) + delete(rawMsg, key) + case "policySetDefinitionId": + err = unpopulate(val, "PolicySetDefinitionID", &c.PolicySetDefinitionID) + delete(rawMsg, key) + case "policySetDefinitionName": + err = unpopulate(val, "PolicySetDefinitionName", &c.PolicySetDefinitionName) + delete(rawMsg, key) + case "policySetDefinitionOwner": + err = unpopulate(val, "PolicySetDefinitionOwner", &c.PolicySetDefinitionOwner) + delete(rawMsg, key) + case "policySetDefinitionParameters": + err = unpopulate(val, "PolicySetDefinitionParameters", &c.PolicySetDefinitionParameters) + delete(rawMsg, key) + case "policySetDefinitionVersion": + err = unpopulate(val, "PolicySetDefinitionVersion", &c.PolicySetDefinitionVersion) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &c.ResourceGroup) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &c.ResourceID) + delete(rawMsg, key) + case "resourceLocation": + err = unpopulate(val, "ResourceLocation", &c.ResourceLocation) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &c.ResourceType) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &c.SubscriptionID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateTimeRFC3339(val, "Timestamp", &c.Timestamp) + delete(rawMsg, key) + default: + if c.AdditionalProperties == nil { + c.AdditionalProperties = map[string]any{} + } + if val != nil { + var aux any + err = json.Unmarshal(val, &aux) + c.AdditionalProperties[key] = aux + } + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ComponentPolicyStatesQueryResults. +func (c ComponentPolicyStatesQueryResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "@odata.context", c.ODataContext) + populate(objectMap, "@odata.count", c.ODataCount) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentPolicyStatesQueryResults. +func (c *ComponentPolicyStatesQueryResults) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "@odata.context": + err = unpopulate(val, "ODataContext", &c.ODataContext) + delete(rawMsg, key) + case "@odata.count": + err = unpopulate(val, "ODataCount", &c.ODataCount) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ComponentStateDetails. func (c ComponentStateDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -764,6 +1086,8 @@ func (f FieldRestriction) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "defaultValue", f.DefaultValue) populate(objectMap, "policy", f.Policy) + populate(objectMap, "policyEffect", f.PolicyEffect) + populate(objectMap, "reason", f.Reason) populate(objectMap, "result", f.Result) populate(objectMap, "values", f.Values) return json.Marshal(objectMap) @@ -784,6 +1108,12 @@ func (f *FieldRestriction) UnmarshalJSON(data []byte) error { case "policy": err = unpopulate(val, "Policy", &f.Policy) delete(rawMsg, key) + case "policyEffect": + err = unpopulate(val, "PolicyEffect", &f.PolicyEffect) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &f.Reason) + delete(rawMsg, key) case "result": err = unpopulate(val, "Result", &f.Result) delete(rawMsg, key) @@ -864,6 +1194,7 @@ func (i *IfNotExistsEvaluationDetails) UnmarshalJSON(data []byte) error { func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) return json.Marshal(objectMap) } @@ -880,6 +1211,9 @@ func (o *Operation) UnmarshalJSON(data []byte) error { case "display": err = unpopulate(val, "Display", &o.Display) delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &o.Name) delete(rawMsg, key) @@ -1125,6 +1459,33 @@ func (p *PolicyDetails) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PolicyEffectDetails. +func (p PolicyEffectDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "policyEffect", p.PolicyEffect) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyEffectDetails. +func (p *PolicyEffectDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "policyEffect": + err = unpopulate(val, "PolicyEffect", &p.PolicyEffect) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type PolicyEvaluationDetails. func (p PolicyEvaluationDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1159,6 +1520,7 @@ func (p *PolicyEvaluationDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PolicyEvaluationResult. func (p PolicyEvaluationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "effectDetails", p.EffectDetails) populate(objectMap, "evaluationDetails", p.EvaluationDetails) populate(objectMap, "evaluationResult", p.EvaluationResult) populate(objectMap, "policyInfo", p.PolicyInfo) @@ -1174,6 +1536,9 @@ func (p *PolicyEvaluationResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "effectDetails": + err = unpopulate(val, "EffectDetails", &p.EffectDetails) + delete(rawMsg, key) case "evaluationDetails": err = unpopulate(val, "EvaluationDetails", &p.EvaluationDetails) delete(rawMsg, key) diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client.go index d38ef07d1d98..edc9abfea12e 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client.go @@ -41,7 +41,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // List - Lists available operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2019-10-01 +// Generated from API version 2022-04-01 // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) @@ -66,7 +66,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2019-10-01") + reqQP.Set("api-version", "2022-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client_example_test.go deleted file mode 100644 index f8d97751921d..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/operations_client_example_test.go +++ /dev/null @@ -1,69 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights" -) - -// 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 -func ExampleOperationsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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"), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/policyevents_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/policyevents_client_example_test.go deleted file mode 100644 index cbe759457ed3..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/policyevents_client_example_test.go +++ /dev/null @@ -1,2227 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForManagementGroupPager_queryAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.8896095Z"); 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.8896095Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForManagementGroupPager_queryAtManagementGroupScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.8896095Z"); 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.8896095Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_filterAndAggregateOnly() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_filterAndGroupWithAggregate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_filterAndGroupWithoutAggregate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_filterAndMultipleGroups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_queryAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6971328Z"); 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.6971328Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_queryAtSubscriptionScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6971328Z"); 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.6971328Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionPager_timeRangeSortSelectAndLimit() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-06T18:00:00Z"); 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.3475017Z"); 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.6135357Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourceGroupPager_queryAtResourceGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6971328Z"); 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.6971328Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourceGroupPager_queryAtResourceGroupScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6971328Z"); 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.6971328Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryAtNestedResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6971328Z"); 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.6971328Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryAtResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.8473851Z"); 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.5842458Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryAtResourceScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.8473851Z"); 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.5842458Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryAtSubscriptionLevelNestedResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6971328Z"); 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.6971328Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryAtSubscriptionLevelResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.8473851Z"); 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.5842458Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryComponentsPolicyEventsCountGroupedByUserAndActionTypeForResourceScopeFilteredByGivenAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.3252921Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourcePager_queryComponentsPolicyEventsForResourceScopeFilteredByGivenAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0367Z"); 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.7682778Z"); 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.3252921Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForPolicySetDefinitionPager_queryAtSubscriptionLevelPolicySetDefinitionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.9539023Z"); 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.9498186Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForPolicySetDefinitionPager_queryAtSubscriptionLevelPolicySetDefinitionScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.9539023Z"); 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.9498186Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForPolicyDefinitionPager_queryAtSubscriptionLevelPolicyDefinitionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.590596Z"); 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.590596Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForPolicyDefinitionPager_queryAtSubscriptionLevelPolicyDefinitionScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.590596Z"); 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.590596Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager_queryAtSubscriptionLevelPolicyAssignmentScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6401747Z"); 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.2017762Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager_queryAtSubscriptionLevelPolicyAssignmentScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.6401747Z"); 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.2017762Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager_queryAtResourceGroupLevelPolicyAssignmentScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.2804863Z"); 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.4302267Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyEventsClient_NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager_queryAtResourceGroupLevelPolicyAssignmentScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.2804863Z"); 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.4302267Z"); return t}()), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/policymetadata_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/policymetadata_client_example_test.go deleted file mode 100644 index d3c73ce7f821..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/policymetadata_client_example_test.go +++ /dev/null @@ -1,157 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExamplePolicyMetadataClient_GetResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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"), - // }, - // } -} - -// 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 -func ExamplePolicyMetadataClient_NewListPager_getCollectionOfPolicyMetadataResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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"), - // }, - // }}, - // } - } -} - -// 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 -func ExamplePolicyMetadataClient_NewListPager_getCollectionOfPolicyMetadataResourcesUsingTopQueryParameter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client.go index 79fdf39cddea..4e2f99f10bb9 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client.go @@ -47,7 +47,7 @@ func NewPolicyRestrictionsClient(subscriptionID string, credential azcore.TokenC // 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 +// Generated from API version 2023-03-01 // - managementGroupID - Management group ID. // - parameters - The check policy restrictions parameters. // - options - PolicyRestrictionsClientCheckAtManagementGroupScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtManagementGroupScope @@ -80,7 +80,7 @@ func (client *PolicyRestrictionsClient) checkAtManagementGroupScopeCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -99,7 +99,7 @@ func (client *PolicyRestrictionsClient) checkAtManagementGroupScopeHandleRespons // 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 +// Generated from API version 2023-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 @@ -135,7 +135,7 @@ func (client *PolicyRestrictionsClient) checkAtResourceGroupScopeCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -153,7 +153,7 @@ func (client *PolicyRestrictionsClient) checkAtResourceGroupScopeHandleResponse( // 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 +// Generated from API version 2023-03-01 // - parameters - The check policy restrictions parameters. // - options - PolicyRestrictionsClientCheckAtSubscriptionScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtSubscriptionScope // method. @@ -184,7 +184,7 @@ func (client *PolicyRestrictionsClient) checkAtSubscriptionScopeCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client_example_test.go deleted file mode 100644 index 3839fdc9e362..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/policyrestrictions_client_example_test.go +++ /dev/null @@ -1,330 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExamplePolicyRestrictionsClient_CheckAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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")}, - // }}, - // }}, - // } -} - -// 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 -func ExamplePolicyRestrictionsClient_CheckAtResourceGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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")}, - // }}, - // }}, - // } -} - -// 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 -func ExamplePolicyRestrictionsClient_CheckAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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")}, - // }}, - // }}, - // } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/policystates_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/policystates_client_example_test.go deleted file mode 100644 index 951314dd2433..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/policystates_client_example_test.go +++ /dev/null @@ -1,4564 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForManagementGroupPager_queryLatestAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:47Z"); 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:47Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForManagementGroupPager_queryLatestAtManagementGroupScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:47Z"); 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:47Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00Z"); 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_filterAndAggregateOnly() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_filterAndGroupWithAggregate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_filterAndGroupWithoutAggregate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_filterAndMultipleGroups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_queryLatestAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:05Z"); 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:05Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_queryLatestAtSubscriptionScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:05Z"); 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:05Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionPager_timeRangeSortSelectAndLimit() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00Z"); 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:00Z"); 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:00Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForSubscription_summarizeAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForSubscription_summarizeAtSubscriptionScopeForAPolicyDefinitionGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourceGroupPager_queryLatestAtResourceGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:42Z"); 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:42Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourceGroupPager_queryLatestAtResourceGroupScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:42Z"); 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:42Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryAllPolicyStatesAtNestedResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:31Z"); 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:31Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryAllPolicyStatesAtResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:31Z"); 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:31Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryAllPolicyStatesAtResourceScopeAndExpandPolicyEvaluationDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:31Z"); 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:31Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryAllPolicyStatesAtResourceScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:31Z"); 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:31Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryAllPolicyStatesAtSubscriptionLevelNestedResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:31Z"); 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:31Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryAllPolicyStatesAtSubscriptionLevelResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:31Z"); 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:31Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryComponentPolicyComplianceStateAtResourceScopeFilteredByGivenAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0367Z"); 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.7682778Z"); 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.6849056Z"); 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.6504951Z"); 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.5523666Z"); 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.3252921Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourcePager_queryComponentPolicyComplianceStateCountGroupedByStateTypeAtResourceScopeFilteredByGivenAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.3252921Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_BeginTriggerSubscriptionEvaluation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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) - } -} - -// 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 -func ExamplePolicyStatesClient_BeginTriggerResourceGroupEvaluation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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) - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForPolicySetDefinitionPager_queryLatestAtSubscriptionLevelPolicySetDefinitionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:58Z"); 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:58Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForPolicySetDefinitionPager_queryLatestAtSubscriptionLevelPolicySetDefinitionScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:58Z"); 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:58Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForPolicySetDefinition() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00Z"); 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForPolicyDefinitionPager_queryLatestAtSubscriptionLevelPolicyDefinitionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:27Z"); 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:27Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForPolicyDefinitionPager_queryLatestAtSubscriptionLevelPolicyDefinitionScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:27Z"); 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:27Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForPolicyDefinition() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager_queryLatestAtSubscriptionLevelPolicyAssignmentScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:19Z"); 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:19Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForSubscriptionLevelPolicyAssignmentPager_queryLatestAtSubscriptionLevelPolicyAssignmentScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:19Z"); 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:19Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForSubscriptionLevelPolicyAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager_queryLatestAtResourceGroupLevelPolicyAssignmentScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:50Z"); 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:50Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_NewListQueryResultsForResourceGroupLevelPolicyAssignmentPager_queryLatestAtResourceGroupLevelPolicyAssignmentScopeWithNextLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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:50Z"); 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:50Z"); return t}()), - // }}, - // } - } -} - -// 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 -func ExamplePolicyStatesClient_SummarizeForResourceGroupLevelPolicyAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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), - // }}, - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/policytrackedresources_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/policytrackedresources_client_example_test.go deleted file mode 100644 index 04b900fcff1e..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/policytrackedresources_client_example_test.go +++ /dev/null @@ -1,591 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForManagementGroupPager_queryAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForManagementGroupPager_queryAtManagementGroupScopeUsingQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForSubscriptionPager_queryAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForSubscriptionPager_queryAtSubscriptionScopeUsingQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForResourceGroupPager_queryAtResourceGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForResourceGroupPager_queryAtResourceGroupScopeUsingQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForResourcePager_queryAtResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExamplePolicyTrackedResourcesClient_NewListQueryResultsForResourcePager_queryAtResourceScopeUsingQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.0000000Z"); 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.0000000Z"); 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.3585243Z"); 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"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/remediations_client_example_test.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/remediations_client_example_test.go deleted file mode 100644 index 9f0023833a49..000000000000 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/remediations_client_example_test.go +++ /dev/null @@ -1,1806 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicyinsights_test - -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" -) - -// 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 -func ExampleRemediationsClient_NewListDeploymentsAtManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.8919106Z"); 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.075918Z"); 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.8761679Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CancelAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListForManagementGroupPager_listRemediationsAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_NewListForManagementGroupPager_listRemediationsAtManagementGroupScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.7531298Z"); 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.7531298Z"); 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"), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListDeploymentsAtSubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.8919106Z"); 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.075918Z"); 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.8761679Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CancelAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListForSubscriptionPager_listRemediationsAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_NewListForSubscriptionPager_listRemediationsAtSubscriptionScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CreateOrUpdateAtSubscription_createRemediationAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.7531298Z"); 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.7531298Z"); 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.7531298Z"); 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.7531298Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_CreateOrUpdateAtSubscription_createRemediationAtSubscriptionScopeWithAllProperties() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.7531298Z"); 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.7531298Z"); 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.7531298Z"); 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.7531298Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_GetAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_DeleteAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListDeploymentsAtResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.8919106Z"); 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.075918Z"); 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.8761679Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CancelAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListForResourceGroupPager_listRemediationsAtResourceGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_NewListForResourceGroupPager_listRemediationsAtResourceGroupScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); 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.4638131Z"); 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.4647478Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CreateOrUpdateAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.7531298Z"); 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.7531298Z"); 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:27Z"); 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:27Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_GetAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_DeleteAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListDeploymentsAtResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.8919106Z"); 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"), - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CancelAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.085918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_NewListForResourcePager_listRemediationsAtIndividualResourceScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.4638131Z"); 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.4647478Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_NewListForResourcePager_listRemediationsAtIndividualResourceScopeWithQueryParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// 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 -func ExampleRemediationsClient_CreateOrUpdateAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.7531298Z"); 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.7531298Z"); 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.7531298Z"); 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.7531298Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_GetAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} - -// 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 -func ExampleRemediationsClient_DeleteAtResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicyinsights.NewClientFactory("", 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.075918Z"); 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.0011706Z"); 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.075918Z"); 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.0011706Z"); return t}()), - // LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"), - // LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser), - // }, - // } -} diff --git a/sdk/resourcemanager/policyinsights/armpolicyinsights/response_types.go b/sdk/resourcemanager/policyinsights/armpolicyinsights/response_types.go index 61955702afd8..00ba006b24d5 100644 --- a/sdk/resourcemanager/policyinsights/armpolicyinsights/response_types.go +++ b/sdk/resourcemanager/policyinsights/armpolicyinsights/response_types.go @@ -69,6 +69,38 @@ type AttestationsClientListForSubscriptionResponse struct { AttestationListResult } +// ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse contains the response from method ComponentPolicyStatesClient.ListQueryResultsForPolicyDefinition. +type ComponentPolicyStatesClientListQueryResultsForPolicyDefinitionResponse struct { + ComponentPolicyStatesQueryResults +} + +// ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse contains the response from method +// ComponentPolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment. +type ComponentPolicyStatesClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse struct { + ComponentPolicyStatesQueryResults +} + +// ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse contains the response from method ComponentPolicyStatesClient.ListQueryResultsForResourceGroup. +type ComponentPolicyStatesClientListQueryResultsForResourceGroupResponse struct { + ComponentPolicyStatesQueryResults +} + +// ComponentPolicyStatesClientListQueryResultsForResourceResponse contains the response from method ComponentPolicyStatesClient.ListQueryResultsForResource. +type ComponentPolicyStatesClientListQueryResultsForResourceResponse struct { + ComponentPolicyStatesQueryResults +} + +// ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse contains the response from method +// ComponentPolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment. +type ComponentPolicyStatesClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse struct { + ComponentPolicyStatesQueryResults +} + +// ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse contains the response from method ComponentPolicyStatesClient.ListQueryResultsForSubscription. +type ComponentPolicyStatesClientListQueryResultsForSubscriptionResponse struct { + ComponentPolicyStatesQueryResults +} + // OperationsClientListResponse contains the response from method OperationsClient.List. type OperationsClientListResponse struct { OperationsListResults