armpolicy

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 15 Imported by: 23

README

Azure Resource Policy Module for Go

The armpolicy module provides operations for working with Azure Resource Policy.

Source code

Getting started

Prerequisites

  • an Azure subscription
  • Supported version of Go (You could download and install the latest version of Go from here. It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this doc.)

Install the package

This project uses Go modules for versioning and dependency management.

Install the Azure Resource Policy module:

go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy

Authorization

When creating a client, you will need to provide a credential for authenticating with Azure Resource Policy. The azidentity module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more.

cred, err := azidentity.NewDefaultAzureCredential(nil)

For more information on authentication, please see the documentation for azidentity at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity.

Client Factory

Azure Resource Policy module consists of one or more clients. We provide a client factory which could be used to create any client in this module.

clientFactory, err := armpolicy.NewClientFactory(<subscription ID>, cred, nil)

You can use ClientOptions in package github.com/Azure/azure-sdk-for-go/sdk/azcore/arm to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for azcore at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore.

options := arm.ClientOptions {
    ClientOptions: azcore.ClientOptions {
        Cloud: cloud.AzureChina,
    },
}
clientFactory, err := armpolicy.NewClientFactory(<subscription ID>, cred, &options)

Clients

A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory.

client := clientFactory.NewAssignmentsClient()

Fakes

The fake package contains types used for constructing in-memory fake servers used in unit tests. This allows writing tests to cover various success/error conditions without the need for connecting to a live service.

Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes.

Provide Feedback

If you encounter bugs or have suggestions, please open an issue and assign the Resource Policy label.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assignment added in v0.2.0

type Assignment struct {
	// The managed identity associated with the policy assignment.
	Identity *Identity

	// The location of the policy assignment. Only required when utilizing managed identity.
	Location *string

	// Properties for the policy assignment.
	Properties *AssignmentProperties

	// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	ID *string

	// READ-ONLY; The name of the resource
	Name *string

	// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData

	// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string
}

Assignment - The policy assignment.

func (Assignment) MarshalJSON added in v0.7.0

func (a Assignment) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Assignment.

func (*Assignment) UnmarshalJSON added in v0.7.0

func (a *Assignment) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Assignment.

type AssignmentListResult added in v0.2.0

type AssignmentListResult struct {
	// REQUIRED; The PolicyAssignment items on this page
	Value []*Assignment

	// The link to the next page of items
	NextLink *string
}

AssignmentListResult - The response of a PolicyAssignment list operation.

func (AssignmentListResult) MarshalJSON added in v0.2.0

func (a AssignmentListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type AssignmentListResult.

func (*AssignmentListResult) UnmarshalJSON added in v0.7.0

func (a *AssignmentListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentListResult.

type AssignmentProperties added in v0.2.0

type AssignmentProperties struct {
	// The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable.
	AssignmentType *AssignmentType

	// The version of the policy definition to use.
	DefinitionVersion *string

	// This message will be part of response in case of policy violation.
	Description *string

	// The display name of the policy assignment.
	DisplayName *string

	// The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll
	EnforcementMode *EnforcementMode

	// The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs.
	Metadata any

	// The messages that describe why a resource is non-compliant with the policy.
	NonComplianceMessages []*NonComplianceMessage

	// The policy's excluded scopes.
	NotScopes []*string

	// The policy property value override.
	Overrides []*Override

	// The parameter values for the assigned policy rule. The keys are the parameter names.
	Parameters map[string]*ParameterValuesValue

	// The ID of the policy definition or policy set definition being assigned.
	PolicyDefinitionID *string

	// The resource selector list to filter policies by resource properties.
	ResourceSelectors []*ResourceSelector

	// READ-ONLY; The effective version of the policy definition in use. This is only present if requested via the $expand query
	// parameter.
	EffectiveDefinitionVersion *string

	// READ-ONLY; The instance ID of the policy assignment. This ID only and always changes when the assignment is deleted and
	// recreated.
	InstanceID *string

	// READ-ONLY; The latest version of the policy definition available. This is only present if requested via the $expand query
	// parameter.
	LatestDefinitionVersion *string

	// READ-ONLY; The scope for the policy assignment.
	Scope *string
}

AssignmentProperties - The policy assignment properties.

func (AssignmentProperties) MarshalJSON added in v0.2.0

func (a AssignmentProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type AssignmentProperties.

func (*AssignmentProperties) UnmarshalJSON added in v0.7.0

func (a *AssignmentProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentProperties.

type AssignmentType added in v1.0.0

type AssignmentType string

AssignmentType - The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable.

const (
	// AssignmentTypeCustom - The custom assignment type.
	AssignmentTypeCustom AssignmentType = "Custom"
	// AssignmentTypeNotSpecified - The not specified assignment type.
	AssignmentTypeNotSpecified AssignmentType = "NotSpecified"
	// AssignmentTypeSystem - The system assignment type.
	AssignmentTypeSystem AssignmentType = "System"
	// AssignmentTypeSystemHidden - The system hidden assignment type.
	AssignmentTypeSystemHidden AssignmentType = "SystemHidden"
)

func PossibleAssignmentTypeValues added in v1.0.0

func PossibleAssignmentTypeValues() []AssignmentType

PossibleAssignmentTypeValues returns the possible values for the AssignmentType const type.

type AssignmentUpdate added in v0.2.0

type AssignmentUpdate struct {
	// The managed identity associated with the policy assignment.
	Identity *Identity

	// The location of the policy assignment. Only required when utilizing managed identity.
	Location *string

	// The policy assignment properties for Patch request.
	Properties *AssignmentUpdateProperties
}

AssignmentUpdate - The policy assignment for Patch request.

func (AssignmentUpdate) MarshalJSON added in v0.2.0

func (a AssignmentUpdate) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type AssignmentUpdate.

func (*AssignmentUpdate) UnmarshalJSON added in v0.7.0

func (a *AssignmentUpdate) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentUpdate.

type AssignmentUpdateProperties added in v0.8.0

type AssignmentUpdateProperties struct {
	// The policy property value override.
	Overrides []*Override

	// The resource selector list to filter policies by resource properties.
	ResourceSelectors []*ResourceSelector
}

AssignmentUpdateProperties - The policy assignment properties for Patch request.

func (AssignmentUpdateProperties) MarshalJSON added in v0.8.0

func (a AssignmentUpdateProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type AssignmentUpdateProperties.

func (*AssignmentUpdateProperties) UnmarshalJSON added in v0.8.0

func (a *AssignmentUpdateProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentUpdateProperties.

type AssignmentsClient added in v0.2.0

type AssignmentsClient struct {
	// contains filtered or unexported fields
}

AssignmentsClient contains the methods for the Assignments group. Don't use this type directly, use NewAssignmentsClient() instead.

func NewAssignmentsClient added in v0.2.0

func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsClient, error)

NewAssignmentsClient creates a new instance of AssignmentsClient with the specified values.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - Contains optional client configuration. Pass nil to accept the default values.

func (*AssignmentsClient) Create added in v0.2.0

func (client *AssignmentsClient) Create(ctx context.Context, scope string, policyAssignmentName string, parameters Assignment, options *AssignmentsClientCreateOptions) (AssignmentsClientCreateResponse, error)

Create - This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • scope - The fully qualified Azure Resource manager identifier of the resource.
  • policyAssignmentName - The name of the policy assignment to get.
  • parameters - Parameters for the policy assignment.
  • options - AssignmentsClientCreateOptions contains the optional parameters for the AssignmentsClient.Create method.
Example (CreateOrUpdateAPolicyAssignment)

Generated from example definition: 2025-03-01/createPolicyAssignment.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{
		Properties: &armpolicy.AssignmentProperties{
			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
			DisplayName: to.Ptr("Enforce resource naming rules"),
			Metadata: map[string]any{
				"assignedBy": "Special Someone",
			},
			NonComplianceMessages: []*armpolicy.NonComplianceMessage{
				{
					Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."),
				},
			},
			Parameters: map[string]*armpolicy.ParameterValuesValue{
				"prefix": {
					Value: "DeptA",
				},
				"suffix": {
					Value: "-LC",
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate)

Generated from example definition: 2025-03-01/createPolicyAssignmentWithEnrollEnforcement.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNamingEnroll", armpolicy.Assignment{
		Properties: &armpolicy.AssignmentProperties{
			Description:     to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
			DisplayName:     to.Ptr("Enforce resource naming rules"),
			EnforcementMode: to.Ptr(armpolicy.EnforcementModeEnroll),
			Metadata: map[string]any{
				"assignedBy": "Special Someone",
			},
			Parameters: map[string]*armpolicy.ParameterValuesValue{
				"prefix": {
					Value: "DeptA",
				},
				"suffix": {
					Value: "-LC",
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentWithASystemAssignedIdentity)

Generated from example definition: 2025-03-01/createPolicyAssignmentWithIdentity.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{
		Identity: &armpolicy.Identity{
			Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
		},
		Location: to.Ptr("eastus"),
		Properties: &armpolicy.AssignmentProperties{
			Description:     to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
			DisplayName:     to.Ptr("Enforce resource naming rules"),
			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
			Metadata: map[string]any{
				"assignedBy": "Foo Bar",
			},
			Parameters: map[string]*armpolicy.ParameterValuesValue{
				"prefix": {
					Value: "DeptA",
				},
				"suffix": {
					Value: "-LC",
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentWithAUserAssignedIdentity)

Generated from example definition: 2025-03-01/createPolicyAssignmentWithUserAssignedIdentity.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{
		Identity: &armpolicy.Identity{
			Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned),
			UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{
				"/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {},
			},
		},
		Location: to.Ptr("eastus"),
		Properties: &armpolicy.AssignmentProperties{
			Description:     to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
			DisplayName:     to.Ptr("Enforce resource naming rules"),
			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
			Metadata: map[string]any{
				"assignedBy": "Foo Bar",
			},
			Parameters: map[string]*armpolicy.ParameterValuesValue{
				"prefix": {
					Value: "DeptA",
				},
				"suffix": {
					Value: "-LC",
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages)

Generated from example definition: 2025-03-01/createPolicyAssignmentNonComplianceMessages.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "securityInitAssignment", armpolicy.Assignment{
		Properties: &armpolicy.AssignmentProperties{
			DisplayName: to.Ptr("Enforce security policies"),
			NonComplianceMessages: []*armpolicy.NonComplianceMessage{
				{
					Message: to.Ptr("Resources must comply with all internal security policies. See <internal site URL> for more info."),
				},
				{
					Message:                     to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."),
					PolicyDefinitionReferenceID: to.Ptr("10420126870854049575"),
				},
				{
					Message:                     to.Ptr("Storage accounts must have firewall rules configured."),
					PolicyDefinitionReferenceID: to.Ptr("8572513655450389710"),
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentWithOverrides)

Generated from example definition: 2025-03-01/createPolicyAssignmentWithOverrides.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.Assignment{
		Properties: &armpolicy.AssignmentProperties{
			Description:       to.Ptr("Limit the resource location and resource SKU"),
			DefinitionVersion: to.Ptr("1.*.*"),
			DisplayName:       to.Ptr("Limit the resource location and resource SKU"),
			Metadata: map[string]any{
				"assignedBy": "Special Someone",
			},
			Overrides: []*armpolicy.Override{
				{
					Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect),
					Selectors: []*armpolicy.Selector{
						{
							In: []*string{
								to.Ptr("Limit_Skus"),
								to.Ptr("Limit_Locations"),
							},
							Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID),
						},
					},
					Value: to.Ptr("Audit"),
				},
				{
					Kind: to.Ptr(armpolicy.OverrideKindDefinitionVersion),
					Selectors: []*armpolicy.Selector{
						{
							In: []*string{
								to.Ptr("eastUSEuap"),
								to.Ptr("centralUSEuap"),
							},
							Kind: to.Ptr(armpolicy.SelectorKindResourceLocation),
						},
					},
					Value: to.Ptr("2.*.*"),
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentWithResourceSelectors)

Generated from example definition: 2025-03-01/createPolicyAssignmentWithResourceSelectors.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.Assignment{
		Properties: &armpolicy.AssignmentProperties{
			Description: to.Ptr("Limit the resource location and resource SKU"),
			DisplayName: to.Ptr("Limit the resource location and resource SKU"),
			Metadata: map[string]any{
				"assignedBy": "Special Someone",
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
			ResourceSelectors: []*armpolicy.ResourceSelector{
				{
					Name: to.Ptr("SDPRegions"),
					Selectors: []*armpolicy.Selector{
						{
							In: []*string{
								to.Ptr("eastus2euap"),
								to.Ptr("centraluseuap"),
							},
							Kind: to.Ptr(armpolicy.SelectorKindResourceLocation),
						},
					},
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate)

Generated from example definition: 2025-03-01/createPolicyAssignmentWithoutEnforcement.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{
		Properties: &armpolicy.AssignmentProperties{
			Description:     to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
			DisplayName:     to.Ptr("Enforce resource naming rules"),
			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDoNotEnforce),
			Metadata: map[string]any{
				"assignedBy": "Special Someone",
			},
			Parameters: map[string]*armpolicy.ParameterValuesValue{
				"prefix": {
					Value: "DeptA",
				},
				"suffix": {
					Value: "-LC",
				},
			},
			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}

func (*AssignmentsClient) CreateByID added in v0.2.0

func (client *AssignmentsClient) CreateByID(ctx context.Context, policyAssignmentID string, parameters Assignment, options *AssignmentsClientCreateByIDOptions) (AssignmentsClientCreateByIDResponse, error)

CreateByID - Creates or updates a policy assignment.

This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyAssignmentID - The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
  • parameters - Parameters for policy assignment.
  • options - AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method.

func (*AssignmentsClient) Delete added in v0.2.0

func (client *AssignmentsClient) Delete(ctx context.Context, scope string, policyAssignmentName string, options *AssignmentsClientDeleteOptions) (AssignmentsClientDeleteResponse, error)

Delete - This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • scope - The fully qualified Azure Resource manager identifier of the resource.
  • policyAssignmentName - The name of the policy assignment to get.
  • options - AssignmentsClientDeleteOptions contains the optional parameters for the AssignmentsClient.Delete method.
Example

Generated from example definition: 2025-03-01/deletePolicyAssignment.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Delete(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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 = armpolicy.AssignmentsClientDeleteResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("EnforceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Enforce resource naming rules"),
	// 			InstanceID: to.Ptr("e4b0f5a6-7c8d-4e9f-8a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 				"prefix": &armpolicy.ParameterValuesValue{
	// 					Value: "DeptA",
	// 				},
	// 				"suffix": &armpolicy.ParameterValuesValue{
	// 					Value: "-LC",
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}

func (*AssignmentsClient) DeleteByID added in v0.2.0

DeleteByID - Deletes a policy assignment.

This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyAssignmentID - The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
  • options - AssignmentsClientDeleteByIDOptions contains the optional parameters for the AssignmentsClient.DeleteByID method.

func (*AssignmentsClient) Get added in v0.2.0

func (client *AssignmentsClient) Get(ctx context.Context, scope string, policyAssignmentName string, options *AssignmentsClientGetOptions) (AssignmentsClientGetResponse, error)

Get - This operation retrieves a single policy assignment, given its name and the scope it was created at. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • scope - The fully qualified Azure Resource manager identifier of the resource.
  • policyAssignmentName - The name of the policy assignment to get.
  • options - AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method.
Example (RetrieveAPolicyAssignment)

Generated from example definition: 2025-03-01/getPolicyAssignment.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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 = armpolicy.AssignmentsClientGetResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("EnforceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Enforce resource naming rules"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("e4b0f5a6-7c8d-4e9f-8a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 				"prefix": &armpolicy.ParameterValuesValue{
	// 					Value: "DeptA",
	// 				},
	// 				"suffix": &armpolicy.ParameterValuesValue{
	// 					Value: "-LC",
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (RetrieveAPolicyAssignmentWithASystemAssignedIdentity)

Generated from example definition: 2025-03-01/getPolicyAssignmentWithIdentity.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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 = armpolicy.AssignmentsClientGetResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("EnforceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
	// 		Identity: &armpolicy.Identity{
	// 			Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
	// 			PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
	// 			TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
	// 		},
	// 		Location: to.Ptr("westus"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Enforce resource naming rules"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("e4b0f5a6-7c8d-4e9f-8a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 				"prefix": &armpolicy.ParameterValuesValue{
	// 					Value: "DeptA",
	// 				},
	// 				"suffix": &armpolicy.ParameterValuesValue{
	// 					Value: "-LC",
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (RetrieveAPolicyAssignmentWithAUserAssignedIdentity)

Generated from example definition: 2025-03-01/getPolicyAssignmentWithUserAssignedIdentity.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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 = armpolicy.AssignmentsClientGetResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("EnforceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
	// 		Identity: &armpolicy.Identity{
	// 			Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned),
	// 			UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{
	// 				"/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{
	// 					ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
	// 					PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
	// 				},
	// 			},
	// 		},
	// 		Location: to.Ptr("westus"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Enforce resource naming rules"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("e4b0f5a6-7c8d-4e9f-8a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 				"prefix": &armpolicy.ParameterValuesValue{
	// 					Value: "DeptA",
	// 				},
	// 				"suffix": &armpolicy.ParameterValuesValue{
	// 					Value: "-LC",
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (RetrieveAPolicyAssignmentWithOverrides)

Generated from example definition: 2025-03-01/getPolicyAssignmentWithOverrides.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", 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 = armpolicy.AssignmentsClientGetResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Limit the resource location and resource SKU"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Limit the resource location and resource SKU"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("d2f3a4b5-c6d7-8e9f-0a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Overrides: []*armpolicy.Override{
	// 				{
	// 					Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect),
	// 					Selectors: []*armpolicy.Selector{
	// 						{
	// 							In: []*string{
	// 								to.Ptr("Limit_Skus"),
	// 								to.Ptr("Limit_Locations"),
	// 							},
	// 							Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID),
	// 						},
	// 					},
	// 					Value: to.Ptr("Audit"),
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (RetrieveAPolicyAssignmentWithResourceSelectors)

Generated from example definition: 2025-03-01/getPolicyAssignmentWithResourceSelectors.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", 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 = armpolicy.AssignmentsClientGetResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Limit the resource location and resource SKU"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Limit the resource location and resource SKU"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("a3c4d5e6-f7a8-9b0c-1d2e-3f4a5b6c7d8e"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 			ResourceSelectors: []*armpolicy.ResourceSelector{
	// 				{
	// 					Name: to.Ptr("SDPRegions"),
	// 					Selectors: []*armpolicy.Selector{
	// 						{
	// 							In: []*string{
	// 								to.Ptr("eastus2euap"),
	// 								to.Ptr("centraluseuap"),
	// 							},
	// 							Kind: to.Ptr(armpolicy.SelectorKindResourceLocation),
	// 						},
	// 					},
	// 				},
	// 			},
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}

func (*AssignmentsClient) GetByID added in v0.2.0

GetByID - Retrieves the policy assignment with the given ID.

The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyAssignmentID - The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
  • options - AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method.

func (*AssignmentsClient) NewListForManagementGroupPager added in v0.5.0

NewListForManagementGroupPager - Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group.

Generated from API version 2025-03-01

  • managementGroupID - The management group ID.
  • options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager method.
Example

Generated from example definition: 2025-03-01/listPolicyAssignmentsForManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAssignmentsClient().NewListForManagementGroupPager("TestManagementGroup", &armpolicy.AssignmentsClientListForManagementGroupOptions{
		Filter: to.Ptr("atScope()"),
		Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion")})
	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 = armpolicy.AssignmentsClientListForManagementGroupResponse{
		// 	AssignmentListResult: armpolicy.AssignmentListResult{
		// 		Value: []*armpolicy.Assignment{
		// 			{
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				Name: to.Ptr("TestCostManagement"),
		// 				Location: to.Ptr("eastus"),
		// 				Identity: &armpolicy.Identity{
		// 					Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
		// 					PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
		// 					TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
		// 				},
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					DisplayName: to.Ptr("Storage Cost Management"),
		// 					Description: to.Ptr("Minimize the risk of accidental cost overruns"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/storageSkus"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					LatestDefinitionVersion: to.Ptr("1.0.0"),
		// 					EffectiveDefinitionVersion: to.Ptr("1.0.0"),
		// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 						"allowedSkus": &armpolicy.ParameterValuesValue{
		// 							Value: "Standard_A1",
		// 						},
		// 					},
		// 					Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"),
		// 					NotScopes: []*string{
		// 					},
		// 					InstanceID: to.Ptr("c7e8f9a0-b1c2-3d4e-5f6a-7b8c9d0e1f2a"),
		// 				},
		// 			},
		// 			{
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				Name: to.Ptr("TestTagEnforcement"),
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					DisplayName: to.Ptr("Enforces a tag key and value"),
		// 					Description: to.Ptr("Ensure a given tag key and value are present on all resources"),
		// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					LatestDefinitionVersion: to.Ptr("1.0.0"),
		// 					EffectiveDefinitionVersion: to.Ptr("1.0.0"),
		// 					Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"),
		// 					NotScopes: []*string{
		// 					},
		// 					InstanceID: to.Ptr("d8f9a0b1-c2d3-4e5f-6a7b-8c9d0e1f2a3b"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*AssignmentsClient) NewListForResourceGroupPager added in v0.5.0

NewListForResourceGroupPager - This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group.

Generated from API version 2025-03-01

  • resourceGroupName - The name of the resource group. The name is case insensitive.
  • options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager method.
Example

Generated from example definition: 2025-03-01/listPolicyAssignmentsForResourceGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAssignmentsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.AssignmentsClientListForResourceGroupOptions{
		Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"),
		Filter: to.Ptr("atScope()")})
	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 = armpolicy.AssignmentsClientListForResourceGroupResponse{
		// 	AssignmentListResult: armpolicy.AssignmentListResult{
		// 		Value: []*armpolicy.Assignment{
		// 			{
		// 				Name: to.Ptr("TestCostManagement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"),
		// 				Identity: &armpolicy.Identity{
		// 					Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
		// 					PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
		// 					TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
		// 				},
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					Description: to.Ptr("Minimize the risk of accidental cost overruns"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					DisplayName: to.Ptr("Storage Cost Management"),
		// 					EffectiveDefinitionVersion: to.Ptr("1.0.0"),
		// 					InstanceID: to.Ptr("a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d"),
		// 					LatestDefinitionVersion: to.Ptr("1.0.0"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					NotScopes: []*string{
		// 					},
		// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 						"allowedSkus": &armpolicy.ParameterValuesValue{
		// 							Value: "Standard_A1",
		// 						},
		// 					},
		// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"),
		// 					Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("TestTagEnforcement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"),
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					Description: to.Ptr("Ensure a given tag key and value are present on all resources"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					DisplayName: to.Ptr("Enforces a tag key and value"),
		// 					EffectiveDefinitionVersion: to.Ptr("1.0.0"),
		// 					InstanceID: to.Ptr("f0b1c2d3-e4f5-6a7b-8c9d-0e1f2a3b4c5d"),
		// 					LatestDefinitionVersion: to.Ptr("1.0.0"),
		// 					NotScopes: []*string{
		// 					},
		// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"),
		// 					Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*AssignmentsClient) NewListForResourcePager added in v0.5.0

func (client *AssignmentsClient) NewListForResourcePager(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *AssignmentsClientListForResourceOptions) *runtime.Pager[AssignmentsClientListForResourceResponse]

NewListForResourcePager - Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == ”, {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').

Generated from API version 2025-03-01

  • resourceGroupName - The name of the resource group. The name is case insensitive.
  • resourceProviderNamespace - The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines)
  • parentResourcePath - The parent resource path. Use empty string if there is none.
  • resourceType - The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites).
  • resourceName - The name of the resource.
  • options - AssignmentsClientListForResourceOptions contains the optional parameters for the AssignmentsClient.NewListForResourcePager method.
Example

Generated from example definition: 2025-03-01/listPolicyAssignmentsForResource.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAssignmentsClient().NewListForResourcePager("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", "MyTestComputer.cloudapp.net", 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 = armpolicy.AssignmentsClientListForResourceResponse{
		// 	AssignmentListResult: armpolicy.AssignmentListResult{
		// 		Value: []*armpolicy.Assignment{
		// 			{
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				Name: to.Ptr("TestCostManagement"),
		// 				Location: to.Ptr("eastus"),
		// 				Identity: &armpolicy.Identity{
		// 					Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
		// 					PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
		// 					TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
		// 				},
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					DisplayName: to.Ptr("VM Cost Management"),
		// 					Description: to.Ptr("Minimize the risk of accidental cost overruns"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/vmSkus"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 						"allowedSkus": &armpolicy.ParameterValuesValue{
		// 							Value: "Standard_A1",
		// 						},
		// 					},
		// 					Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"),
		// 					NotScopes: []*string{
		// 					},
		// 					InstanceID: to.Ptr("e9a0b1c2-d3e4-5f6a-7b8c-9d0e1f2a3b4c"),
		// 				},
		// 			},
		// 			{
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				Name: to.Ptr("TestTagEnforcement"),
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					DisplayName: to.Ptr("Enforces a tag key and value"),
		// 					Description: to.Ptr("Ensure a given tag key and value are present on all resources"),
		// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"),
		// 					NotScopes: []*string{
		// 					},
		// 					InstanceID: to.Ptr("f0b1c2d3-e4f5-6a7b-8c9d-0e1f2a3b4c5d"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*AssignmentsClient) NewListPager added in v0.5.0

NewListPager - Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}.

Generated from API version 2025-03-01

  • options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method.
Example

Generated from example definition: 2025-03-01/listPolicyAssignments.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAssignmentsClient().NewListPager(&armpolicy.AssignmentsClientListOptions{
		Filter: to.Ptr("atScope()"),
		Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion")})
	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 = armpolicy.AssignmentsClientListResponse{
		// 	AssignmentListResult: armpolicy.AssignmentListResult{
		// 		Value: []*armpolicy.Assignment{
		// 			{
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				Name: to.Ptr("CostManagement"),
		// 				Location: to.Ptr("eastus"),
		// 				Identity: &armpolicy.Identity{
		// 					Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
		// 					PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
		// 					TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
		// 				},
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					DisplayName: to.Ptr("Storage Cost Management"),
		// 					Description: to.Ptr("Minimize the risk of accidental cost overruns"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					LatestDefinitionVersion: to.Ptr("1.0.0"),
		// 					EffectiveDefinitionVersion: to.Ptr("1.0.0"),
		// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 						"allowedSkus": &armpolicy.ParameterValuesValue{
		// 							Value: "Standard_A1",
		// 						},
		// 					},
		// 					Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
		// 					NotScopes: []*string{
		// 					},
		// 					InstanceID: to.Ptr("a3c4d5e6-f7a8-9b0c-1d2e-3f4a5b6c7d8e"),
		// 				},
		// 			},
		// 			{
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/TagEnforcement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
		// 				Name: to.Ptr("TagEnforcement"),
		// 				Properties: &armpolicy.AssignmentProperties{
		// 					DisplayName: to.Ptr("Enforces a tag key and value"),
		// 					Description: to.Ptr("Ensure a given tag key and value are present on all resources"),
		// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"),
		// 					DefinitionVersion: to.Ptr("1.*.*"),
		// 					LatestDefinitionVersion: to.Ptr("1.0.0"),
		// 					EffectiveDefinitionVersion: to.Ptr("1.0.0"),
		// 					Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
		// 					NotScopes: []*string{
		// 					},
		// 					InstanceID: to.Ptr("b6d7e8f9-a0b1-2c3d-4e5f-6a7b8c9d0e1f"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*AssignmentsClient) Update added in v0.2.0

func (client *AssignmentsClient) Update(ctx context.Context, scope string, policyAssignmentName string, parameters AssignmentUpdate, options *AssignmentsClientUpdateOptions) (AssignmentsClientUpdateResponse, error)

Update - This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • scope - The fully qualified Azure Resource manager identifier of the resource.
  • policyAssignmentName - The name of the policy assignment to get.
  • parameters - Parameters for policy assignment patch request.
  • options - AssignmentsClientUpdateOptions contains the optional parameters for the AssignmentsClient.Update method.
Example (UpdateAPolicyAssignmentWithASystemAssignedIdentity)

Generated from example definition: 2025-03-01/updatePolicyAssignmentWithIdentity.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{
		Identity: &armpolicy.Identity{
			Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
		},
		Location: to.Ptr("eastus"),
	}, 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 = armpolicy.AssignmentsClientUpdateResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("EnforceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
	// 		Identity: &armpolicy.Identity{
	// 			Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
	// 			PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
	// 			TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
	// 		},
	// 		Location: to.Ptr("eastus"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Enforce resource naming rules"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("e4b0f5a6-7c8d-4e9f-8a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 				"prefix": &armpolicy.ParameterValuesValue{
	// 					Value: "DeptA",
	// 				},
	// 				"suffix": &armpolicy.ParameterValuesValue{
	// 					Value: "-LC",
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (UpdateAPolicyAssignmentWithAUserAssignedIdentity)

Generated from example definition: 2025-03-01/updatePolicyAssignmentWithUserAssignedIdentity.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{
		Identity: &armpolicy.Identity{
			Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned),
			UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{
				"/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {},
			},
		},
		Location: to.Ptr("eastus"),
	}, 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 = armpolicy.AssignmentsClientUpdateResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("EnforceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
	// 		Identity: &armpolicy.Identity{
	// 			Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned),
	// 			UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{
	// 				"/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{
	// 					ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
	// 					PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
	// 				},
	// 			},
	// 		},
	// 		Location: to.Ptr("eastus"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Enforce resource naming rules"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("e4b0f5a6-7c8d-4e9f-8a1b-2c3d4e5f6a7b"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 				"prefix": &armpolicy.ParameterValuesValue{
	// 					Value: "DeptA",
	// 				},
	// 				"suffix": &armpolicy.ParameterValuesValue{
	// 					Value: "-LC",
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (UpdateAPolicyAssignmentWithOverrides)

Generated from example definition: 2025-03-01/updatePolicyAssignmentWithOverrides.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.AssignmentUpdate{
		Properties: &armpolicy.AssignmentUpdateProperties{
			Overrides: []*armpolicy.Override{
				{
					Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect),
					Selectors: []*armpolicy.Selector{
						{
							In: []*string{
								to.Ptr("Limit_Skus"),
								to.Ptr("Limit_Locations"),
							},
							Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID),
						},
					},
					Value: to.Ptr("Audit"),
				},
			},
		},
	}, 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 = armpolicy.AssignmentsClientUpdateResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Limit the resource location and resource SKU"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Limit the resource location and resource SKU"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("a3c4d5e6-f7a8-9b0c-1d2e-3f4a5b6c7d8e"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			Overrides: []*armpolicy.Override{
	// 				{
	// 					Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect),
	// 					Selectors: []*armpolicy.Selector{
	// 						{
	// 							In: []*string{
	// 								to.Ptr("Limit_Skus"),
	// 								to.Ptr("Limit_Locations"),
	// 							},
	// 							Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID),
	// 						},
	// 					},
	// 					Value: to.Ptr("Audit"),
	// 				},
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}
Example (UpdateAPolicyAssignmentWithResourceSelectors)

Generated from example definition: 2025-03-01/updatePolicyAssignmentWithResourceSelectors.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.AssignmentUpdate{
		Properties: &armpolicy.AssignmentUpdateProperties{
			ResourceSelectors: []*armpolicy.ResourceSelector{
				{
					Name: to.Ptr("SDPRegions"),
					Selectors: []*armpolicy.Selector{
						{
							In: []*string{
								to.Ptr("eastus2euap"),
								to.Ptr("centraluseuap"),
							},
							Kind: to.Ptr(armpolicy.SelectorKindResourceLocation),
						},
					},
				},
			},
		},
	}, 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 = armpolicy.AssignmentsClientUpdateResponse{
	// 	Assignment: &armpolicy.Assignment{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
	// 		Properties: &armpolicy.AssignmentProperties{
	// 			Description: to.Ptr("Limit the resource location and resource SKU"),
	// 			DefinitionVersion: to.Ptr("1.*.*"),
	// 			DisplayName: to.Ptr("Limit the resource location and resource SKU"),
	// 			EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
	// 			InstanceID: to.Ptr("a3c4d5e6-f7a8-9b0c-1d2e-3f4a5b6c7d8e"),
	// 			Metadata: map[string]any{
	// 				"assignedBy": "Special Someone",
	// 			},
	// 			NotScopes: []*string{
	// 			},
	// 			PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 			ResourceSelectors: []*armpolicy.ResourceSelector{
	// 				{
	// 					Name: to.Ptr("SDPRegions"),
	// 					Selectors: []*armpolicy.Selector{
	// 						{
	// 							In: []*string{
	// 								to.Ptr("eastus2euap"),
	// 								to.Ptr("centraluseuap"),
	// 							},
	// 							Kind: to.Ptr(armpolicy.SelectorKindResourceLocation),
	// 						},
	// 					},
	// 				},
	// 			},
	// 			Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
	// 		},
	// 	},
	// }
}

func (*AssignmentsClient) UpdateByID added in v0.2.0

func (client *AssignmentsClient) UpdateByID(ctx context.Context, policyAssignmentID string, parameters AssignmentUpdate, options *AssignmentsClientUpdateByIDOptions) (AssignmentsClientUpdateByIDResponse, error)

UpdateByID - Updates a policy assignment.

This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyAssignmentID - The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
  • parameters - Parameters for policy assignment patch request.
  • options - AssignmentsClientUpdateByIDOptions contains the optional parameters for the AssignmentsClient.UpdateByID method.

type AssignmentsClientCreateByIDOptions added in v0.2.0

type AssignmentsClientCreateByIDOptions struct {
}

AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method.

type AssignmentsClientCreateByIDResponse added in v0.2.0

type AssignmentsClientCreateByIDResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientCreateByIDResponse contains the response from method AssignmentsClient.CreateByID.

type AssignmentsClientCreateOptions added in v0.2.0

type AssignmentsClientCreateOptions struct {
}

AssignmentsClientCreateOptions contains the optional parameters for the AssignmentsClient.Create method.

type AssignmentsClientCreateResponse added in v0.2.0

type AssignmentsClientCreateResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientCreateResponse contains the response from method AssignmentsClient.Create.

type AssignmentsClientDeleteByIDOptions added in v0.2.0

type AssignmentsClientDeleteByIDOptions struct {
}

AssignmentsClientDeleteByIDOptions contains the optional parameters for the AssignmentsClient.DeleteByID method.

type AssignmentsClientDeleteByIDResponse added in v0.2.0

type AssignmentsClientDeleteByIDResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientDeleteByIDResponse contains the response from method AssignmentsClient.DeleteByID.

type AssignmentsClientDeleteOptions added in v0.2.0

type AssignmentsClientDeleteOptions struct {
}

AssignmentsClientDeleteOptions contains the optional parameters for the AssignmentsClient.Delete method.

type AssignmentsClientDeleteResponse added in v0.2.0

type AssignmentsClientDeleteResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientDeleteResponse contains the response from method AssignmentsClient.Delete.

type AssignmentsClientGetByIDOptions added in v0.2.0

type AssignmentsClientGetByIDOptions struct {
}

AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method.

type AssignmentsClientGetByIDResponse added in v0.2.0

type AssignmentsClientGetByIDResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientGetByIDResponse contains the response from method AssignmentsClient.GetByID.

type AssignmentsClientGetOptions added in v0.2.0

type AssignmentsClientGetOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method.

type AssignmentsClientGetResponse added in v0.2.0

type AssignmentsClientGetResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientGetResponse contains the response from method AssignmentsClient.Get.

type AssignmentsClientListForManagementGroupOptions added in v0.2.0

type AssignmentsClientListForManagementGroupOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list
	// only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied
	// to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes
	// all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list
	// includes all policy assignments of the policy definition whose id is {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager method.

type AssignmentsClientListForManagementGroupResponse added in v0.2.0

type AssignmentsClientListForManagementGroupResponse struct {
	// The response of a PolicyAssignment list operation.
	AssignmentListResult
}

AssignmentsClientListForManagementGroupResponse contains the response from method AssignmentsClient.NewListForManagementGroupPager.

type AssignmentsClientListForResourceGroupOptions added in v0.2.0

type AssignmentsClientListForResourceGroupOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list
	// only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied
	// to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes
	// all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list
	// includes all policy assignments of the policy definition whose id is {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager method.

type AssignmentsClientListForResourceGroupResponse added in v0.2.0

type AssignmentsClientListForResourceGroupResponse struct {
	// The response of a PolicyAssignment list operation.
	AssignmentListResult
}

AssignmentsClientListForResourceGroupResponse contains the response from method AssignmentsClient.NewListForResourceGroupPager.

type AssignmentsClientListForResourceOptions added in v0.2.0

type AssignmentsClientListForResourceOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list
	// only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied
	// to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes
	// all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list
	// includes all policy assignments of the policy definition whose id is {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

AssignmentsClientListForResourceOptions contains the optional parameters for the AssignmentsClient.NewListForResourcePager method.

type AssignmentsClientListForResourceResponse added in v0.2.0

type AssignmentsClientListForResourceResponse struct {
	// The response of a PolicyAssignment list operation.
	AssignmentListResult
}

AssignmentsClientListForResourceResponse contains the response from method AssignmentsClient.NewListForResourcePager.

type AssignmentsClientListOptions added in v0.2.0

type AssignmentsClientListOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list
	// only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied
	// to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes
	// all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list
	// includes all policy assignments of the policy definition whose id is {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method.

type AssignmentsClientListResponse added in v0.2.0

type AssignmentsClientListResponse struct {
	// The response of a PolicyAssignment list operation.
	AssignmentListResult
}

AssignmentsClientListResponse contains the response from method AssignmentsClient.NewListPager.

type AssignmentsClientUpdateByIDOptions added in v0.2.0

type AssignmentsClientUpdateByIDOptions struct {
}

AssignmentsClientUpdateByIDOptions contains the optional parameters for the AssignmentsClient.UpdateByID method.

type AssignmentsClientUpdateByIDResponse added in v0.2.0

type AssignmentsClientUpdateByIDResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientUpdateByIDResponse contains the response from method AssignmentsClient.UpdateByID.

type AssignmentsClientUpdateOptions added in v0.2.0

type AssignmentsClientUpdateOptions struct {
}

AssignmentsClientUpdateOptions contains the optional parameters for the AssignmentsClient.Update method.

type AssignmentsClientUpdateResponse added in v0.2.0

type AssignmentsClientUpdateResponse struct {
	// The policy assignment.
	Assignment
}

AssignmentsClientUpdateResponse contains the response from method AssignmentsClient.Update.

type ClientFactory added in v0.7.0

type ClientFactory struct {
	// contains filtered or unexported fields
}

ClientFactory is a client factory used to create any client in this module. Don't use this type directly, use NewClientFactory instead.

func NewClientFactory added in v0.7.0

func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error)

NewClientFactory creates a new instance of ClientFactory with the specified values. The parameter values will be propagated to any client created from this factory.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - pass nil to accept the default values.

func (*ClientFactory) NewAssignmentsClient added in v0.7.0

func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient

NewAssignmentsClient creates a new instance of AssignmentsClient.

func (*ClientFactory) NewDefinitionVersionsClient added in v0.10.0

func (c *ClientFactory) NewDefinitionVersionsClient() *DefinitionVersionsClient

NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient.

func (*ClientFactory) NewDefinitionsClient added in v0.7.0

func (c *ClientFactory) NewDefinitionsClient() *DefinitionsClient

NewDefinitionsClient creates a new instance of DefinitionsClient.

func (*ClientFactory) NewSetDefinitionVersionsClient added in v0.10.0

func (c *ClientFactory) NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient

NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient.

func (*ClientFactory) NewSetDefinitionsClient added in v0.7.0

func (c *ClientFactory) NewSetDefinitionsClient() *SetDefinitionsClient

NewSetDefinitionsClient creates a new instance of SetDefinitionsClient.

func (*ClientFactory) NewTokensClient added in v1.0.0

func (c *ClientFactory) NewTokensClient() *TokensClient

NewTokensClient creates a new instance of TokensClient.

type CreatedByType

type CreatedByType string

CreatedByType - The kind of entity that created the resource.

const (
	// CreatedByTypeApplication - The entity was created by an application.
	CreatedByTypeApplication CreatedByType = "Application"
	// CreatedByTypeKey - The entity was created by a key.
	CreatedByTypeKey CreatedByType = "Key"
	// CreatedByTypeManagedIdentity - The entity was created by a managed identity.
	CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity"
	// CreatedByTypeUser - The entity was created by a user.
	CreatedByTypeUser CreatedByType = "User"
)

func PossibleCreatedByTypeValues

func PossibleCreatedByTypeValues() []CreatedByType

PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type.

type Definition added in v0.2.0

type Definition struct {
	// The policy definition properties.
	Properties *DefinitionProperties

	// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	ID *string

	// READ-ONLY; The name of the resource
	Name *string

	// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData

	// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string
}

Definition - The policy definition.

func (Definition) MarshalJSON added in v0.7.0

func (d Definition) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Definition.

func (*Definition) UnmarshalJSON added in v0.7.0

func (d *Definition) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Definition.

type DefinitionGroup added in v0.2.0

type DefinitionGroup struct {
	// REQUIRED; The name of the group.
	Name *string

	// A resource ID of a resource that contains additional metadata about the group.
	AdditionalMetadataID *string

	// The group's category.
	Category *string

	// The group's description.
	Description *string

	// The group's display name.
	DisplayName *string
}

DefinitionGroup - The policy definition group.

func (DefinitionGroup) MarshalJSON added in v0.7.0

func (d DefinitionGroup) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionGroup.

func (*DefinitionGroup) UnmarshalJSON added in v0.7.0

func (d *DefinitionGroup) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionGroup.

type DefinitionListResult added in v0.2.0

type DefinitionListResult struct {
	// REQUIRED; The PolicyDefinition items on this page
	Value []*Definition

	// The link to the next page of items
	NextLink *string
}

DefinitionListResult - The response of a PolicyDefinition list operation.

func (DefinitionListResult) MarshalJSON added in v0.2.0

func (d DefinitionListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionListResult.

func (*DefinitionListResult) UnmarshalJSON added in v0.7.0

func (d *DefinitionListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionListResult.

type DefinitionProperties added in v0.2.0

type DefinitionProperties struct {
	// The policy definition description.
	Description *string

	// The display name of the policy definition.
	DisplayName *string

	// The details of the source of external evaluation results required by the policy during enforcement evaluation.
	ExternalEvaluationEnforcementSettings *ExternalEvaluationEnforcementSettings

	// The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs.
	Metadata any

	// The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data.
	Mode *string

	// The parameter definitions for parameters used in the policy rule. The keys are the parameter names.
	Parameters map[string]*ParameterDefinitionsValue

	// The policy rule.
	PolicyRule any

	// The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.
	PolicyType *PolicyType

	// The policy definition version in #.#.# format.
	Version *string

	// A list of available versions for this policy definition.
	Versions []*string
}

DefinitionProperties - The policy definition properties.

func (DefinitionProperties) MarshalJSON added in v0.2.0

func (d DefinitionProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionProperties.

func (*DefinitionProperties) UnmarshalJSON added in v0.7.0

func (d *DefinitionProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionProperties.

type DefinitionReference added in v0.2.0

type DefinitionReference struct {
	// REQUIRED; The ID of the policy definition or policy set definition.
	PolicyDefinitionID *string

	// The version of the policy definition to use.
	DefinitionVersion *string

	// The name of the groups that this policy definition reference belongs to.
	GroupNames []*string

	// The parameter values for the referenced policy rule. The keys are the parameter names.
	Parameters map[string]*ParameterValuesValue

	// A unique id (within the policy set definition) for this policy definition reference.
	PolicyDefinitionReferenceID *string

	// READ-ONLY; The effective version of the policy definition in use. This is only present if requested via the $expand query
	// parameter.
	EffectiveDefinitionVersion *string

	// READ-ONLY; The latest version of the policy definition available. This is only present if requested via the $expand query
	// parameter.
	LatestDefinitionVersion *string
}

DefinitionReference - The policy definition reference.

func (DefinitionReference) MarshalJSON added in v0.2.0

func (d DefinitionReference) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionReference.

func (*DefinitionReference) UnmarshalJSON added in v0.7.0

func (d *DefinitionReference) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionReference.

type DefinitionVersion added in v0.10.0

type DefinitionVersion struct {
	// The policy definition version properties.
	Properties *DefinitionVersionProperties

	// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	ID *string

	// READ-ONLY; The name of the resource
	Name *string

	// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData

	// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string
}

DefinitionVersion - The ID of the policy definition version.

func (DefinitionVersion) MarshalJSON added in v0.10.0

func (d DefinitionVersion) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionVersion.

func (*DefinitionVersion) UnmarshalJSON added in v0.10.0

func (d *DefinitionVersion) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersion.

type DefinitionVersionListResult added in v0.10.0

type DefinitionVersionListResult struct {
	// REQUIRED; The PolicyDefinitionVersion items on this page
	Value []*DefinitionVersion

	// The link to the next page of items
	NextLink *string
}

DefinitionVersionListResult - The response of a PolicyDefinitionVersion list operation.

func (DefinitionVersionListResult) MarshalJSON added in v0.10.0

func (d DefinitionVersionListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionVersionListResult.

func (*DefinitionVersionListResult) UnmarshalJSON added in v0.10.0

func (d *DefinitionVersionListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersionListResult.

type DefinitionVersionProperties added in v0.10.0

type DefinitionVersionProperties struct {
	// The policy definition description.
	Description *string

	// The display name of the policy definition.
	DisplayName *string

	// The details of the source of external evaluation results required by the policy during enforcement evaluation.
	ExternalEvaluationEnforcementSettings *ExternalEvaluationEnforcementSettings

	// The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs.
	Metadata any

	// The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data.
	Mode *string

	// The parameter definitions for parameters used in the policy rule. The keys are the parameter names.
	Parameters map[string]*ParameterDefinitionsValue

	// The policy rule.
	PolicyRule any

	// The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.
	PolicyType *PolicyType

	// The policy definition version in #.#.# format.
	Version *string
}

DefinitionVersionProperties - The policy definition properties.

func (DefinitionVersionProperties) MarshalJSON added in v0.10.0

func (d DefinitionVersionProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type DefinitionVersionProperties.

func (*DefinitionVersionProperties) UnmarshalJSON added in v0.10.0

func (d *DefinitionVersionProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersionProperties.

type DefinitionVersionsClient added in v0.10.0

type DefinitionVersionsClient struct {
	// contains filtered or unexported fields
}

DefinitionVersionsClient contains the methods for the DefinitionVersions group. Don't use this type directly, use NewDefinitionVersionsClient() instead.

func NewDefinitionVersionsClient added in v0.10.0

func NewDefinitionVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionVersionsClient, error)

NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient with the specified values.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - Contains optional client configuration. Pass nil to accept the default values.

func (*DefinitionVersionsClient) CreateOrUpdate added in v0.10.0

func (client *DefinitionVersionsClient) CreateOrUpdate(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateOptions) (DefinitionVersionsClientCreateOrUpdateResponse, error)

CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • parameters - The policy definition properties.
  • options - DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate method.
Example

Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().CreateOrUpdate(ctx, "ResourceNaming", "1.2.1", armpolicy.DefinitionVersion{
		Properties: &armpolicy.DefinitionVersionProperties{
			Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"),
			DisplayName: to.Ptr("Enforce resource naming convention"),
			Metadata: map[string]any{
				"category": "Naming",
			},
			Mode: to.Ptr("All"),
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"prefix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name prefix"),
						DisplayName: to.Ptr("Prefix"),
					},
				},
				"suffix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name suffix"),
						DisplayName: to.Ptr("Suffix"),
					},
				},
			},
			PolicyRule: map[string]any{
				"if": map[string]any{
					"not": map[string]any{
						"field": "name",
						"like":  "[concat(parameters('prefix'), '*', parameters('suffix'))]",
					},
				},
				"then": map[string]any{
					"effect": "deny",
				},
			},
			Version: to.Ptr("1.2.1"),
		},
	}, 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 = armpolicy.DefinitionVersionsClientCreateOrUpdateResponse{
	// 	DefinitionVersion: &armpolicy.DefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
	// 		Properties: &armpolicy.DefinitionVersionProperties{
	// 			Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 			DisplayName: to.Ptr("Naming Convention"),
	// 			Metadata: map[string]any{
	// 				"category": "Naming",
	// 			},
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"prefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name prefix"),
	// 						DisplayName: to.Ptr("Prefix"),
	// 					},
	// 				},
	// 				"suffix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name suffix"),
	// 						DisplayName: to.Ptr("Suffix"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"not": map[string]any{
	// 						"field": "name",
	// 						"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) CreateOrUpdateAtManagementGroup added in v0.10.0

func (client *DefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, policyDefinitionName string, policyDefinitionVersion string, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)

CreateOrUpdateAtManagementGroup - This operation creates or updates a policy definition version in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • parameters - The policy definition properties.
  • options - DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", armpolicy.DefinitionVersion{
		Properties: &armpolicy.DefinitionVersionProperties{
			Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"),
			DisplayName: to.Ptr("Enforce resource naming convention"),
			Metadata: map[string]any{
				"category": "Naming",
			},
			Mode: to.Ptr("All"),
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"prefix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name prefix"),
						DisplayName: to.Ptr("Prefix"),
					},
				},
				"suffix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name suffix"),
						DisplayName: to.Ptr("Suffix"),
					},
				},
			},
			PolicyRule: map[string]any{
				"if": map[string]any{
					"not": map[string]any{
						"field": "name",
						"like":  "[concat(parameters('prefix'), '*', parameters('suffix'))]",
					},
				},
				"then": map[string]any{
					"effect": "deny",
				},
			},
			Version: to.Ptr("1.2.1"),
		},
	}, 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 = armpolicy.DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{
	// 	DefinitionVersion: &armpolicy.DefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
	// 		Properties: &armpolicy.DefinitionVersionProperties{
	// 			Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 			DisplayName: to.Ptr("Naming Convention"),
	// 			Metadata: map[string]any{
	// 				"category": "Naming",
	// 			},
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"prefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name prefix"),
	// 						DisplayName: to.Ptr("Prefix"),
	// 					},
	// 				},
	// 				"suffix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name suffix"),
	// 						DisplayName: to.Ptr("Suffix"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"not": map[string]any{
	// 						"field": "name",
	// 						"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) Delete added in v0.10.0

func (client *DefinitionVersionsClient) Delete(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, options *DefinitionVersionsClientDeleteOptions) (DefinitionVersionsClientDeleteResponse, error)

Delete - This operation deletes the policy definition version in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete method.
Example

Generated from example definition: 2025-03-01/deletePolicyDefinitionVersion.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().Delete(ctx, "ResourceNaming", "1.2.1", 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 = armpolicy.DefinitionVersionsClientDeleteResponse{
	// }
}

func (*DefinitionVersionsClient) DeleteAtManagementGroup added in v0.10.0

func (client *DefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, policyDefinitionName string, policyDefinitionVersion string, options *DefinitionVersionsClientDeleteAtManagementGroupOptions) (DefinitionVersionsClientDeleteAtManagementGroupResponse, error)

DeleteAtManagementGroup - This operation deletes the policy definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", 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 = armpolicy.DefinitionVersionsClientDeleteAtManagementGroupResponse{
	// }
}

func (*DefinitionVersionsClient) Get added in v0.10.0

func (client *DefinitionVersionsClient) Get(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, options *DefinitionVersionsClientGetOptions) (DefinitionVersionsClientGetResponse, error)

Get - This operation retrieves the policy definition version in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method.
Example

Generated from example definition: 2025-03-01/getPolicyDefinitionVersion.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().Get(ctx, "ResourceNaming", "1.2.1", 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 = armpolicy.DefinitionVersionsClientGetResponse{
	// 	DefinitionVersion: &armpolicy.DefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
	// 		Properties: &armpolicy.DefinitionVersionProperties{
	// 			Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 			DisplayName: to.Ptr("Naming Convention"),
	// 			Metadata: map[string]any{
	// 				"category": "Naming",
	// 			},
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"prefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name prefix"),
	// 						DisplayName: to.Ptr("Prefix"),
	// 					},
	// 				},
	// 				"suffix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name suffix"),
	// 						DisplayName: to.Ptr("Suffix"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"not": map[string]any{
	// 						"field": "name",
	// 						"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) GetAtManagementGroup added in v0.10.0

func (client *DefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, policyDefinitionName string, policyDefinitionVersion string, options *DefinitionVersionsClientGetAtManagementGroupOptions) (DefinitionVersionsClientGetAtManagementGroupResponse, error)

GetAtManagementGroup - This operation retrieves the policy definition version in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", 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 = armpolicy.DefinitionVersionsClientGetAtManagementGroupResponse{
	// 	DefinitionVersion: &armpolicy.DefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
	// 		Properties: &armpolicy.DefinitionVersionProperties{
	// 			Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 			DisplayName: to.Ptr("Naming Convention"),
	// 			Metadata: map[string]any{
	// 				"category": "Naming",
	// 			},
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"prefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name prefix"),
	// 						DisplayName: to.Ptr("Prefix"),
	// 					},
	// 				},
	// 				"suffix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name suffix"),
	// 						DisplayName: to.Ptr("Suffix"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"not": map[string]any{
	// 						"field": "name",
	// 						"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) GetBuiltIn added in v0.10.0

func (client *DefinitionVersionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, options *DefinitionVersionsClientGetBuiltInOptions) (DefinitionVersionsClientGetBuiltInResponse, error)

GetBuiltIn - This operation retrieves the built-in policy definition version with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition.
  • policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn method.
Example

Generated from example definition: 2025-03-01/getBuiltinPolicyDefinitionVersion.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().GetBuiltIn(ctx, "7433c107-6db4-4ad1-b57a-a76dce0154a1", "1.2.1", 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 = armpolicy.DefinitionVersionsClientGetBuiltInResponse{
	// 	DefinitionVersion: &armpolicy.DefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1/versions/1.2.1"),
	// 		Properties: &armpolicy.DefinitionVersionProperties{
	// 			Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."),
	// 			DisplayName: to.Ptr("Allowed storage account SKUs"),
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeArray),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("The list of SKUs that can be specified for storage accounts."),
	// 						DisplayName: to.Ptr("Allowed SKUs"),
	// 						StrongType: to.Ptr("StorageSKUs"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"allOf": []any{
	// 						map[string]any{
	// 							"equals": "Microsoft.Storage/storageAccounts",
	// 							"field": "type",
	// 						},
	// 						map[string]any{
	// 							"not": map[string]any{
	// 								"field": "Microsoft.Storage/storageAccounts/sku.name",
	// 								"in": "[parameters('listOfAllowedSKUs')]",
	// 							},
	// 						},
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "Deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) ListAll added in v0.10.0

ListAll - Lists all policy definition versions within a subscription.

This operation lists all the policy definition versions for all policy definitions within a subscription. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • options - DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll method.
Example

Generated from example definition: 2025-03-01/listAllPolicyDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().ListAll(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 = armpolicy.DefinitionVersionsClientListAllResponse{
	// 	DefinitionVersionListResult: &armpolicy.DefinitionVersionListResult{
	// 		Value: []*armpolicy.DefinitionVersion{
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
	// 				Properties: &armpolicy.DefinitionVersionProperties{
	// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 					DisplayName: to.Ptr("Naming Convention"),
	// 					Metadata: map[string]any{
	// 						"category": "Naming",
	// 					},
	// 					Mode: to.Ptr("All"),
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 						"prefix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name prefix"),
	// 								DisplayName: to.Ptr("Prefix"),
	// 							},
	// 						},
	// 						"suffix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name suffix"),
	// 								DisplayName: to.Ptr("Suffix"),
	// 							},
	// 						},
	// 					},
	// 					PolicyRule: map[string]any{
	// 						"if": map[string]any{
	// 							"not": map[string]any{
	// 								"field": "name",
	// 								"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 							},
	// 						},
	// 						"then": map[string]any{
	// 							"effect": "deny",
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 			{
	// 				Name: to.Ptr("1.0.0"),
	// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
	// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.0.0"),
	// 				Properties: &armpolicy.DefinitionVersionProperties{
	// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 					DisplayName: to.Ptr("Naming Convention"),
	// 					Metadata: map[string]any{
	// 						"category": "Naming",
	// 					},
	// 					Mode: to.Ptr("All"),
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 						"prefix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name prefix"),
	// 								DisplayName: to.Ptr("Prefix"),
	// 							},
	// 						},
	// 						"suffix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name suffix"),
	// 								DisplayName: to.Ptr("Suffix"),
	// 							},
	// 						},
	// 					},
	// 					PolicyRule: map[string]any{
	// 						"if": map[string]any{
	// 							"not": map[string]any{
	// 								"field": "name",
	// 								"like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]",
	// 							},
	// 						},
	// 						"then": map[string]any{
	// 							"effect": "deny",
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 					Version: to.Ptr("1.0.0"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) ListAllAtManagementGroup added in v0.10.0

ListAllAtManagementGroup - Lists all policy definition versions at management group scope.

This operation lists all the policy definition versions for all policy definitions at the management group scope. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • options - DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().ListAllAtManagementGroup(ctx, "MyManagementGroup", 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 = armpolicy.DefinitionVersionsClientListAllAtManagementGroupResponse{
	// 	DefinitionVersionListResult: &armpolicy.DefinitionVersionListResult{
	// 		Value: []*armpolicy.DefinitionVersion{
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
	// 				Properties: &armpolicy.DefinitionVersionProperties{
	// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 					DisplayName: to.Ptr("Naming Convention"),
	// 					Metadata: map[string]any{
	// 						"category": "Naming",
	// 					},
	// 					Mode: to.Ptr("All"),
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 						"prefix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name prefix"),
	// 								DisplayName: to.Ptr("Prefix"),
	// 							},
	// 						},
	// 						"suffix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name suffix"),
	// 								DisplayName: to.Ptr("Suffix"),
	// 							},
	// 						},
	// 					},
	// 					PolicyRule: map[string]any{
	// 						"if": map[string]any{
	// 							"not": map[string]any{
	// 								"field": "name",
	// 								"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 							},
	// 						},
	// 						"then": map[string]any{
	// 							"effect": "deny",
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 			{
	// 				Name: to.Ptr("1.0.0"),
	// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.0.0"),
	// 				Properties: &armpolicy.DefinitionVersionProperties{
	// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 					DisplayName: to.Ptr("Naming Convention"),
	// 					Metadata: map[string]any{
	// 						"category": "Naming",
	// 					},
	// 					Mode: to.Ptr("All"),
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 						"prefix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name prefix"),
	// 								DisplayName: to.Ptr("Prefix"),
	// 							},
	// 						},
	// 						"suffix": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								Description: to.Ptr("Resource name suffix"),
	// 								DisplayName: to.Ptr("Suffix"),
	// 							},
	// 						},
	// 					},
	// 					PolicyRule: map[string]any{
	// 						"if": map[string]any{
	// 							"not": map[string]any{
	// 								"field": "name",
	// 								"like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]",
	// 							},
	// 						},
	// 						"then": map[string]any{
	// 							"effect": "deny",
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) ListAllBuiltins added in v0.10.0

ListAllBuiltins - Lists all built-in policy definition versions.

This operation lists all the built-in policy definition versions for all built-in policy definitions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • options - DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins method.
Example

Generated from example definition: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionVersionsClient().ListAllBuiltins(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 = armpolicy.DefinitionVersionsClientListAllBuiltinsResponse{
	// 	DefinitionVersionListResult: &armpolicy.DefinitionVersionListResult{
	// 		Value: []*armpolicy.DefinitionVersion{
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.2.1"),
	// 				Properties: &armpolicy.DefinitionVersionProperties{
	// 					Description: to.Ptr("Audit DB level audit setting for SQL databases"),
	// 					DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"),
	// 					Mode: to.Ptr("All"),
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 						"setting": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							AllowedValues: []any{
	// 								"enabled",
	// 								"disabled",
	// 							},
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								DisplayName: to.Ptr("Audit Setting"),
	// 							},
	// 						},
	// 					},
	// 					PolicyRule: map[string]any{
	// 						"if": map[string]any{
	// 							"equals": "Microsoft.Sql/servers/databases",
	// 							"field": "type",
	// 						},
	// 						"then": map[string]any{
	// 							"effect": "AuditIfNotExists",
	// 							"details": map[string]any{
	// 								"name": "default",
	// 								"type": "Microsoft.Sql/servers/databases/auditingSettings",
	// 								"existenceCondition": map[string]any{
	// 									"allOf": []any{
	// 										map[string]any{
	// 											"equals": "[parameters('setting')]",
	// 											"field": "Microsoft.Sql/auditingSettings.state",
	// 										},
	// 									},
	// 								},
	// 							},
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 			{
	// 				Name: to.Ptr("1.0.0"),
	// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.0.0"),
	// 				Properties: &armpolicy.DefinitionVersionProperties{
	// 					Description: to.Ptr("Audit DB level audit setting for SQL databases"),
	// 					DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"),
	// 					Mode: to.Ptr("All"),
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 						"setting": &armpolicy.ParameterDefinitionsValue{
	// 							Type: to.Ptr(armpolicy.ParameterTypeString),
	// 							AllowedValues: []any{
	// 								"enabled",
	// 								"disabled",
	// 								"default",
	// 							},
	// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 								DisplayName: to.Ptr("Audit Setting"),
	// 							},
	// 						},
	// 					},
	// 					PolicyRule: map[string]any{
	// 						"if": map[string]any{
	// 							"equals": "Microsoft.Sql/servers/databases",
	// 							"field": "type",
	// 						},
	// 						"then": map[string]any{
	// 							"effect": "AuditIfNotExists",
	// 							"details": map[string]any{
	// 								"name": "default",
	// 								"type": "Microsoft.Sql/servers/databases/auditingSettings",
	// 								"existenceCondition": map[string]any{
	// 									"allOf": []any{
	// 										map[string]any{
	// 											"equals": "[parameters('setting')]",
	// 											"field": "Microsoft.Sql/auditingSettings.state",
	// 										},
	// 									},
	// 								},
	// 							},
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 					Version: to.Ptr("1.0.0"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*DefinitionVersionsClient) NewListBuiltInPager added in v0.10.0

NewListBuiltInPager - This operation retrieves a list of all the built-in policy definition versions for the given policy definition.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition.
  • options - DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager method.
Example

Generated from example definition: 2025-03-01/listBuiltInPolicyDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewDefinitionVersionsClient().NewListBuiltInPager("06a78e20-9358-41c9-923c-fb736d382a12", 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 = armpolicy.DefinitionVersionsClientListBuiltInResponse{
		// 	DefinitionVersionListResult: armpolicy.DefinitionVersionListResult{
		// 		Value: []*armpolicy.DefinitionVersion{
		// 			{
		// 				Name: to.Ptr("1.2.1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.2.1"),
		// 				Properties: &armpolicy.DefinitionVersionProperties{
		// 					Description: to.Ptr("Audit DB level audit setting for SQL databases"),
		// 					DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"),
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"setting": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							AllowedValues: []any{
		// 								"enabled",
		// 								"disabled",
		// 							},
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								DisplayName: to.Ptr("Audit Setting"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"equals": "Microsoft.Sql/servers/databases",
		// 							"field": "type",
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "AuditIfNotExists",
		// 							"details": map[string]any{
		// 								"name": "default",
		// 								"type": "Microsoft.Sql/servers/databases/auditingSettings",
		// 								"existenceCondition": map[string]any{
		// 									"allOf": []any{
		// 										map[string]any{
		// 											"equals": "[parameters('setting')]",
		// 											"field": "Microsoft.Sql/auditingSettings.state",
		// 										},
		// 									},
		// 								},
		// 							},
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("1.0.0"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.0.0"),
		// 				Properties: &armpolicy.DefinitionVersionProperties{
		// 					Description: to.Ptr("Audit DB level audit setting for SQL databases"),
		// 					DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"),
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"setting": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							AllowedValues: []any{
		// 								"enabled",
		// 								"disabled",
		// 								"default",
		// 							},
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								DisplayName: to.Ptr("Audit Setting"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"equals": "Microsoft.Sql/servers/databases",
		// 							"field": "type",
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "AuditIfNotExists",
		// 							"details": map[string]any{
		// 								"name": "default",
		// 								"type": "Microsoft.Sql/servers/databases/auditingSettings",
		// 								"existenceCondition": map[string]any{
		// 									"allOf": []any{
		// 										map[string]any{
		// 											"equals": "[parameters('setting')]",
		// 											"field": "Microsoft.Sql/auditingSettings.state",
		// 										},
		// 									},
		// 								},
		// 							},
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.0.0"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*DefinitionVersionsClient) NewListByManagementGroupPager added in v0.10.0

func (client *DefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, policyDefinitionName string, options *DefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionVersionsClientListByManagementGroupResponse]

NewListByManagementGroupPager - This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policyDefinitionName - The name of the policy definition.
  • options - DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager method.
Example

Generated from example definition: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "ResourceNaming", 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 = armpolicy.DefinitionVersionsClientListByManagementGroupResponse{
		// 	DefinitionVersionListResult: armpolicy.DefinitionVersionListResult{
		// 		Value: []*armpolicy.DefinitionVersion{
		// 			{
		// 				Name: to.Ptr("1.2.1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
		// 				Properties: &armpolicy.DefinitionVersionProperties{
		// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
		// 					DisplayName: to.Ptr("Naming Convention"),
		// 					Metadata: map[string]any{
		// 						"category": "Naming",
		// 					},
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"prefix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name prefix"),
		// 								DisplayName: to.Ptr("Prefix"),
		// 							},
		// 						},
		// 						"suffix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name suffix"),
		// 								DisplayName: to.Ptr("Suffix"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"not": map[string]any{
		// 								"field": "name",
		// 								"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("1.0.0"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.0.0"),
		// 				Properties: &armpolicy.DefinitionVersionProperties{
		// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
		// 					DisplayName: to.Ptr("Naming Convention"),
		// 					Metadata: map[string]any{
		// 						"category": "Naming",
		// 					},
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"prefix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name prefix"),
		// 								DisplayName: to.Ptr("Prefix"),
		// 							},
		// 						},
		// 						"suffix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name suffix"),
		// 								DisplayName: to.Ptr("Suffix"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"not": map[string]any{
		// 								"field": "name",
		// 								"like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]",
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*DefinitionVersionsClient) NewListPager added in v0.10.0

NewListPager - This operation retrieves a list of all the policy definition versions for the given policy definition.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition.
  • options - DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager method.
Example

Generated from example definition: 2025-03-01/listPolicyDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewDefinitionVersionsClient().NewListPager("ResourceNaming", 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 = armpolicy.DefinitionVersionsClientListResponse{
		// 	DefinitionVersionListResult: armpolicy.DefinitionVersionListResult{
		// 		Value: []*armpolicy.DefinitionVersion{
		// 			{
		// 				Name: to.Ptr("1.2.1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"),
		// 				Properties: &armpolicy.DefinitionVersionProperties{
		// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
		// 					DisplayName: to.Ptr("Naming Convention"),
		// 					Metadata: map[string]any{
		// 						"category": "Naming",
		// 					},
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"prefix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name prefix"),
		// 								DisplayName: to.Ptr("Prefix"),
		// 							},
		// 						},
		// 						"suffix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name suffix"),
		// 								DisplayName: to.Ptr("Suffix"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"not": map[string]any{
		// 								"field": "name",
		// 								"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("1.0.0"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.0.0"),
		// 				Properties: &armpolicy.DefinitionVersionProperties{
		// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
		// 					DisplayName: to.Ptr("Naming Convention"),
		// 					Metadata: map[string]any{
		// 						"category": "Naming",
		// 					},
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"prefix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name prefix"),
		// 								DisplayName: to.Ptr("Prefix"),
		// 							},
		// 						},
		// 						"suffix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name suffix"),
		// 								DisplayName: to.Ptr("Suffix"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"not": map[string]any{
		// 								"field": "name",
		// 								"like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]",
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.0.0"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

type DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions added in v0.10.0

type DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct {
}

DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup method.

type DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse added in v0.10.0

type DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct {
	// The ID of the policy definition version.
	DefinitionVersion
}

DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionVersionsClient.CreateOrUpdateAtManagementGroup.

type DefinitionVersionsClientCreateOrUpdateOptions added in v0.10.0

type DefinitionVersionsClientCreateOrUpdateOptions struct {
}

DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate method.

type DefinitionVersionsClientCreateOrUpdateResponse added in v0.10.0

type DefinitionVersionsClientCreateOrUpdateResponse struct {
	// The ID of the policy definition version.
	DefinitionVersion
}

DefinitionVersionsClientCreateOrUpdateResponse contains the response from method DefinitionVersionsClient.CreateOrUpdate.

type DefinitionVersionsClientDeleteAtManagementGroupOptions added in v0.10.0

type DefinitionVersionsClientDeleteAtManagementGroupOptions struct {
}

DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup method.

type DefinitionVersionsClientDeleteAtManagementGroupResponse added in v0.10.0

type DefinitionVersionsClientDeleteAtManagementGroupResponse struct {
}

DefinitionVersionsClientDeleteAtManagementGroupResponse contains the response from method DefinitionVersionsClient.DeleteAtManagementGroup.

type DefinitionVersionsClientDeleteOptions added in v0.10.0

type DefinitionVersionsClientDeleteOptions struct {
}

DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete method.

type DefinitionVersionsClientDeleteResponse added in v0.10.0

type DefinitionVersionsClientDeleteResponse struct {
}

DefinitionVersionsClientDeleteResponse contains the response from method DefinitionVersionsClient.Delete.

type DefinitionVersionsClientGetAtManagementGroupOptions added in v0.10.0

type DefinitionVersionsClientGetAtManagementGroupOptions struct {
}

DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup method.

type DefinitionVersionsClientGetAtManagementGroupResponse added in v0.10.0

type DefinitionVersionsClientGetAtManagementGroupResponse struct {
	// The ID of the policy definition version.
	DefinitionVersion
}

DefinitionVersionsClientGetAtManagementGroupResponse contains the response from method DefinitionVersionsClient.GetAtManagementGroup.

type DefinitionVersionsClientGetBuiltInOptions added in v0.10.0

type DefinitionVersionsClientGetBuiltInOptions struct {
}

DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn method.

type DefinitionVersionsClientGetBuiltInResponse added in v0.10.0

type DefinitionVersionsClientGetBuiltInResponse struct {
	// The ID of the policy definition version.
	DefinitionVersion
}

DefinitionVersionsClientGetBuiltInResponse contains the response from method DefinitionVersionsClient.GetBuiltIn.

type DefinitionVersionsClientGetOptions added in v0.10.0

type DefinitionVersionsClientGetOptions struct {
}

DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method.

type DefinitionVersionsClientGetResponse added in v0.10.0

type DefinitionVersionsClientGetResponse struct {
	// The ID of the policy definition version.
	DefinitionVersion
}

DefinitionVersionsClientGetResponse contains the response from method DefinitionVersionsClient.Get.

type DefinitionVersionsClientListAllAtManagementGroupOptions added in v0.10.0

type DefinitionVersionsClientListAllAtManagementGroupOptions struct {
}

DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup method.

type DefinitionVersionsClientListAllAtManagementGroupResponse added in v0.10.0

type DefinitionVersionsClientListAllAtManagementGroupResponse struct {
	// The response of a PolicyDefinitionVersion list operation.
	DefinitionVersionListResult
}

DefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method DefinitionVersionsClient.ListAllAtManagementGroup.

type DefinitionVersionsClientListAllBuiltinsOptions added in v0.10.0

type DefinitionVersionsClientListAllBuiltinsOptions struct {
}

DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins method.

type DefinitionVersionsClientListAllBuiltinsResponse added in v0.10.0

type DefinitionVersionsClientListAllBuiltinsResponse struct {
	// The response of a PolicyDefinitionVersion list operation.
	DefinitionVersionListResult
}

DefinitionVersionsClientListAllBuiltinsResponse contains the response from method DefinitionVersionsClient.ListAllBuiltins.

type DefinitionVersionsClientListAllOptions added in v0.10.0

type DefinitionVersionsClientListAllOptions struct {
}

DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll method.

type DefinitionVersionsClientListAllResponse added in v0.10.0

type DefinitionVersionsClientListAllResponse struct {
	// The response of a PolicyDefinitionVersion list operation.
	DefinitionVersionListResult
}

DefinitionVersionsClientListAllResponse contains the response from method DefinitionVersionsClient.ListAll.

type DefinitionVersionsClientListBuiltInOptions added in v0.10.0

type DefinitionVersionsClientListBuiltInOptions struct {
	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager method.

type DefinitionVersionsClientListBuiltInResponse added in v0.10.0

type DefinitionVersionsClientListBuiltInResponse struct {
	// The response of a PolicyDefinitionVersion list operation.
	DefinitionVersionListResult
}

DefinitionVersionsClientListBuiltInResponse contains the response from method DefinitionVersionsClient.NewListBuiltInPager.

type DefinitionVersionsClientListByManagementGroupOptions added in v0.10.0

type DefinitionVersionsClientListByManagementGroupOptions struct {
	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager method.

type DefinitionVersionsClientListByManagementGroupResponse added in v0.10.0

type DefinitionVersionsClientListByManagementGroupResponse struct {
	// The response of a PolicyDefinitionVersion list operation.
	DefinitionVersionListResult
}

DefinitionVersionsClientListByManagementGroupResponse contains the response from method DefinitionVersionsClient.NewListByManagementGroupPager.

type DefinitionVersionsClientListOptions added in v0.10.0

type DefinitionVersionsClientListOptions struct {
	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager method.

type DefinitionVersionsClientListResponse added in v0.10.0

type DefinitionVersionsClientListResponse struct {
	// The response of a PolicyDefinitionVersion list operation.
	DefinitionVersionListResult
}

DefinitionVersionsClientListResponse contains the response from method DefinitionVersionsClient.NewListPager.

type DefinitionsClient added in v0.2.0

type DefinitionsClient struct {
	// contains filtered or unexported fields
}

DefinitionsClient contains the methods for the Definitions group. Don't use this type directly, use NewDefinitionsClient() instead.

func NewDefinitionsClient added in v0.2.0

func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionsClient, error)

NewDefinitionsClient creates a new instance of DefinitionsClient with the specified values.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - Contains optional client configuration. Pass nil to accept the default values.

func (*DefinitionsClient) CreateOrUpdate added in v0.2.0

func (client *DefinitionsClient) CreateOrUpdate(ctx context.Context, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateOptions) (DefinitionsClientCreateOrUpdateResponse, error)

CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition to get.
  • parameters - The policy definition properties.
  • options - DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate method.
Example (CreateOrUpdateAPolicyDefinition)

Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinition.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "ResourceNaming", armpolicy.Definition{
		Properties: &armpolicy.DefinitionProperties{
			Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"),
			DisplayName: to.Ptr("Enforce resource naming convention"),
			Metadata: map[string]any{
				"category": "Naming",
			},
			Mode: to.Ptr("All"),
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"prefix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name prefix"),
						DisplayName: to.Ptr("Prefix"),
					},
				},
				"suffix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name suffix"),
						DisplayName: to.Ptr("Suffix"),
					},
				},
			},
			PolicyRule: map[string]any{
				"if": map[string]any{
					"not": map[string]any{
						"field": "name",
						"like":  "[concat(parameters('prefix'), '*', parameters('suffix'))]",
					},
				},
				"then": map[string]any{
					"effect": "deny",
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyDefinitionWithAdvancedParameters)

Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionAdvancedParams.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "EventHubDiagnosticLogs", armpolicy.Definition{
		Properties: &armpolicy.DefinitionProperties{
			Description: to.Ptr("Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised"),
			DisplayName: to.Ptr("Event Hubs should have diagnostic logging enabled"),
			Metadata: map[string]any{
				"category": "Event Hub",
			},
			Mode: to.Ptr("Indexed"),
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"requiredRetentionDays": {
					Type: to.Ptr(armpolicy.ParameterTypeInteger),
					AllowedValues: []any{
						0,
						30,
						90,
						180,
						365,
					},
					DefaultValue: 365,
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("The required diagnostic logs retention in days"),
						DisplayName: to.Ptr("Required retention (days)"),
					},
				},
			},
			PolicyRule: map[string]any{
				"if": map[string]any{
					"equals": "Microsoft.EventHub/namespaces",
					"field":  "type",
				},
				"then": map[string]any{
					"effect": "AuditIfNotExists",
					"details": map[string]any{
						"type": "Microsoft.Insights/diagnosticSettings",
						"existenceCondition": map[string]any{
							"allOf": []any{
								map[string]any{
									"equals": "true",
									"field":  "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled",
								},
								map[string]any{
									"equals": "[parameters('requiredRetentionDays')]",
									"field":  "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days",
								},
							},
						},
					},
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Example (CreateOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings)

Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "RandomizeVMAllocation", armpolicy.Definition{
		Properties: &armpolicy.DefinitionProperties{
			Description: to.Ptr("Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values."),
			DisplayName: to.Ptr("Randomize VM Allocation"),
			ExternalEvaluationEnforcementSettings: &armpolicy.ExternalEvaluationEnforcementSettings{
				EndpointSettings: &armpolicy.ExternalEvaluationEndpointSettings{
					Kind: to.Ptr("CoinFlip"),
					Details: map[string]any{
						"successProbability": 0.5,
					},
				},
				MissingTokenAction: to.Ptr("audit"),
				RoleDefinitionIDs: []*string{
					to.Ptr("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b"),
				},
			},
			Metadata: map[string]any{
				"category": "VM",
			},
			Mode: to.Ptr("Indexed"),
			PolicyRule: map[string]any{
				"if": map[string]any{
					"allOf": []any{
						map[string]any{
							"equals": "Microsoft.Compute/virtualMachines",
							"field":  "type",
						},
						map[string]any{
							"equals": "eastus",
							"field":  "location",
						},
						map[string]any{
							"equals": "false",
							"value":  "[claims().isValid]",
						},
					},
				},
				"then": map[string]any{
					"effect": "deny",
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}

func (*DefinitionsClient) CreateOrUpdateAtManagementGroup added in v0.2.0

func (client *DefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionsClientCreateOrUpdateAtManagementGroupResponse, error)

CreateOrUpdateAtManagementGroup - This operation creates or updates a policy definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • policyDefinitionName - The name of the policy definition to get.
  • parameters - The policy definition properties.
  • options - DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", armpolicy.Definition{
		Properties: &armpolicy.DefinitionProperties{
			Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"),
			DisplayName: to.Ptr("Enforce resource naming convention"),
			Metadata: map[string]any{
				"category": "Naming",
			},
			Mode: to.Ptr("All"),
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"prefix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name prefix"),
						DisplayName: to.Ptr("Prefix"),
					},
				},
				"suffix": {
					Type: to.Ptr(armpolicy.ParameterTypeString),
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						Description: to.Ptr("Resource name suffix"),
						DisplayName: to.Ptr("Suffix"),
					},
				},
			},
			PolicyRule: map[string]any{
				"if": map[string]any{
					"not": map[string]any{
						"field": "name",
						"like":  "[concat(parameters('prefix'), '*', parameters('suffix'))]",
					},
				},
				"then": map[string]any{
					"effect": "deny",
				},
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}

func (*DefinitionsClient) Delete added in v0.2.0

func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionName string, options *DefinitionsClientDeleteOptions) (DefinitionsClientDeleteResponse, error)

Delete - This operation deletes the policy definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition to get.
  • options - DefinitionsClientDeleteOptions contains the optional parameters for the DefinitionsClient.Delete method.
Example

Generated from example definition: 2025-03-01/deletePolicyDefinition.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionsClient().Delete(ctx, "ResourceNaming", 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 = armpolicy.DefinitionsClientDeleteResponse{
	// }
}

func (*DefinitionsClient) DeleteAtManagementGroup added in v0.2.0

func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientDeleteAtManagementGroupOptions) (DefinitionsClientDeleteAtManagementGroupResponse, error)

DeleteAtManagementGroup - This operation deletes the policy definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • policyDefinitionName - The name of the policy definition to get.
  • options - DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", 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 = armpolicy.DefinitionsClientDeleteAtManagementGroupResponse{
	// }
}

func (*DefinitionsClient) Get added in v0.2.0

func (client *DefinitionsClient) Get(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetOptions) (DefinitionsClientGetResponse, error)

Get - This operation retrieves the policy definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the policy definition to get.
  • options - DefinitionsClientGetOptions contains the optional parameters for the DefinitionsClient.Get method.
Example

Generated from example definition: 2025-03-01/getPolicyDefinition.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionsClient().Get(ctx, "ResourceNaming", 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 = armpolicy.DefinitionsClientGetResponse{
	// 	Definition: &armpolicy.Definition{
	// 		Name: to.Ptr("ResourceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 		Properties: &armpolicy.DefinitionProperties{
	// 			Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 			DisplayName: to.Ptr("Naming Convention"),
	// 			Metadata: map[string]any{
	// 				"category": "Naming",
	// 			},
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"prefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name prefix"),
	// 						DisplayName: to.Ptr("Prefix"),
	// 					},
	// 				},
	// 				"suffix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name suffix"),
	// 						DisplayName: to.Ptr("Suffix"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"not": map[string]any{
	// 						"field": "name",
	// 						"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*DefinitionsClient) GetAtManagementGroup added in v0.2.0

func (client *DefinitionsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientGetAtManagementGroupOptions) (DefinitionsClientGetAtManagementGroupResponse, error)

GetAtManagementGroup - This operation retrieves the policy definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • policyDefinitionName - The name of the policy definition to get.
  • options - DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/getPolicyDefinitionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", 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 = armpolicy.DefinitionsClientGetAtManagementGroupResponse{
	// 	Definition: &armpolicy.Definition{
	// 		Name: to.Ptr("ResourceNaming"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 		Properties: &armpolicy.DefinitionProperties{
	// 			Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
	// 			DisplayName: to.Ptr("Naming Convention"),
	// 			Metadata: map[string]any{
	// 				"category": "Naming",
	// 			},
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"prefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name prefix"),
	// 						DisplayName: to.Ptr("Prefix"),
	// 					},
	// 				},
	// 				"suffix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("Resource name suffix"),
	// 						DisplayName: to.Ptr("Suffix"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"not": map[string]any{
	// 						"field": "name",
	// 						"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*DefinitionsClient) GetBuiltIn added in v0.2.0

func (client *DefinitionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetBuiltInOptions) (DefinitionsClientGetBuiltInResponse, error)

GetBuiltIn - This operation retrieves the built-in policy definition with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policyDefinitionName - The name of the built-in policy definition to get.
  • options - DefinitionsClientGetBuiltInOptions contains the optional parameters for the DefinitionsClient.GetBuiltIn method.
Example

Generated from example definition: 2025-03-01/getBuiltinPolicyDefinition.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDefinitionsClient().GetBuiltIn(ctx, "7433c107-6db4-4ad1-b57a-a76dce0154a1", 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 = armpolicy.DefinitionsClientGetBuiltInResponse{
	// 	Definition: &armpolicy.Definition{
	// 		Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 		Properties: &armpolicy.DefinitionProperties{
	// 			Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."),
	// 			DisplayName: to.Ptr("Allowed storage account SKUs"),
	// 			Mode: to.Ptr("All"),
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeArray),
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						Description: to.Ptr("The list of SKUs that can be specified for storage accounts."),
	// 						DisplayName: to.Ptr("Allowed SKUs"),
	// 						StrongType: to.Ptr("StorageSKUs"),
	// 					},
	// 				},
	// 			},
	// 			PolicyRule: map[string]any{
	// 				"if": map[string]any{
	// 					"allOf": []any{
	// 						map[string]any{
	// 							"equals": "Microsoft.Storage/storageAccounts",
	// 							"field": "type",
	// 						},
	// 						map[string]any{
	// 							"not": map[string]any{
	// 								"field": "Microsoft.Storage/storageAccounts/sku.name",
	// 								"in": "[parameters('listOfAllowedSKUs')]",
	// 							},
	// 						},
	// 					},
	// 				},
	// 				"then": map[string]any{
	// 					"effect": "Deny",
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*DefinitionsClient) NewListBuiltInPager added in v0.5.0

NewListBuiltInPager - This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}.

Generated from API version 2025-03-01

  • options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager method.
Example

Generated from example definition: 2025-03-01/listBuiltInPolicyDefinitions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewDefinitionsClient().NewListBuiltInPager(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 = armpolicy.DefinitionsClientListBuiltInResponse{
		// 	DefinitionListResult: armpolicy.DefinitionListResult{
		// 		Value: []*armpolicy.Definition{
		// 			{
		// 				Name: to.Ptr("06a78e20-9358-41c9-923c-fb736d382a12"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("Audit DB level audit setting for SQL databases"),
		// 					DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"),
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"setting": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							AllowedValues: []any{
		// 								"enabled",
		// 								"disabled",
		// 							},
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								DisplayName: to.Ptr("Audit Setting"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"equals": "Microsoft.Sql/servers/databases",
		// 							"field": "type",
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "AuditIfNotExists",
		// 							"details": map[string]any{
		// 								"name": "default",
		// 								"type": "Microsoft.Sql/servers/databases/auditingSettings",
		// 								"existenceCondition": map[string]any{
		// 									"allOf": []any{
		// 										map[string]any{
		// 											"equals": "[parameters('setting')]",
		// 											"field": "Microsoft.Sql/auditingSettings.state",
		// 										},
		// 									},
		// 								},
		// 							},
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."),
		// 					DisplayName: to.Ptr("Allowed storage account SKUs"),
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeArray),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("The list of SKUs that can be specified for storage accounts."),
		// 								DisplayName: to.Ptr("Allowed SKUs"),
		// 								StrongType: to.Ptr("StorageSKUs"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"allOf": []any{
		// 								map[string]any{
		// 									"equals": "Microsoft.Storage/storageAccounts",
		// 									"field": "type",
		// 								},
		// 								map[string]any{
		// 									"not": map[string]any{
		// 										"field": "Microsoft.Storage/storageAccounts/sku.name",
		// 										"in": "[parameters('listOfAllowedSKUs')]",
		// 									},
		// 								},
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "Deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeStatic),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("abeed54a-73c5-441d-8a8c-6b5e7a0c299e"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/abeed54a-73c5-441d-8a8c-6b5e7a0c299e"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."),
		// 					DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"),
		// 					Metadata: map[string]any{
		// 						"category": "KeyVault DataPlane",
		// 					},
		// 					Mode: to.Ptr("Microsoft.KeyVault.Data"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"daysToExpire": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeInteger),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("The number of days for a certificate to expire."),
		// 								DisplayName: to.Ptr("Days to expire"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn",
		// 							"lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]",
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "audit",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*DefinitionsClient) NewListByManagementGroupPager added in v0.5.0

NewListByManagementGroupPager - This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}”. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • options - DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager method.
Example

Generated from example definition: 2025-03-01/listPolicyDefinitionsByManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", 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 = armpolicy.DefinitionsClientListByManagementGroupResponse{
		// 	DefinitionListResult: armpolicy.DefinitionListResult{
		// 		Value: []*armpolicy.Definition{
		// 			{
		// 				Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."),
		// 					DisplayName: to.Ptr("Allowed storage account SKUs"),
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeArray),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("The list of SKUs that can be specified for storage accounts."),
		// 								DisplayName: to.Ptr("Allowed SKUs"),
		// 								StrongType: to.Ptr("StorageSKUs"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"allOf": []any{
		// 								map[string]any{
		// 									"equals": "Microsoft.Storage/storageAccounts",
		// 									"field": "type",
		// 								},
		// 								map[string]any{
		// 									"not": map[string]any{
		// 										"field": "Microsoft.Storage/storageAccounts/sku.name",
		// 										"in": "[parameters('listOfAllowedSKUs')]",
		// 									},
		// 								},
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "Deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("ResourceNaming"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
		// 					DisplayName: to.Ptr("Naming Convention"),
		// 					Metadata: map[string]any{
		// 						"category": "Naming",
		// 					},
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"prefix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name prefix"),
		// 								DisplayName: to.Ptr("Prefix"),
		// 							},
		// 						},
		// 						"suffix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name suffix"),
		// 								DisplayName: to.Ptr("Suffix"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"not": map[string]any{
		// 								"field": "name",
		// 								"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*DefinitionsClient) NewListPager added in v0.5.0

NewListPager - This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}”. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}.

Generated from API version 2025-03-01

  • options - DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.NewListPager method.
Example

Generated from example definition: 2025-03-01/listPolicyDefinitions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewDefinitionsClient().NewListPager(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 = armpolicy.DefinitionsClientListResponse{
		// 	DefinitionListResult: armpolicy.DefinitionListResult{
		// 		Value: []*armpolicy.Definition{
		// 			{
		// 				Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."),
		// 					DisplayName: to.Ptr("Allowed storage account SKUs"),
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeArray),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("The list of SKUs that can be specified for storage accounts."),
		// 								DisplayName: to.Ptr("Allowed SKUs"),
		// 								StrongType: to.Ptr("StorageSKUs"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"allOf": []any{
		// 								map[string]any{
		// 									"equals": "Microsoft.Storage/storageAccounts",
		// 									"field": "type",
		// 								},
		// 								map[string]any{
		// 									"not": map[string]any{
		// 										"field": "Microsoft.Storage/storageAccounts/sku.name",
		// 										"in": "[parameters('listOfAllowedSKUs')]",
		// 									},
		// 								},
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "Deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("ResourceNaming"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"),
		// 					DisplayName: to.Ptr("Naming Convention"),
		// 					Metadata: map[string]any{
		// 						"category": "Naming",
		// 					},
		// 					Mode: to.Ptr("All"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"prefix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name prefix"),
		// 								DisplayName: to.Ptr("Prefix"),
		// 							},
		// 						},
		// 						"suffix": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeString),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("Resource name suffix"),
		// 								DisplayName: to.Ptr("Suffix"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"not": map[string]any{
		// 								"field": "name",
		// 								"like": "[concat(parameters('prefix'), '*', parameters('suffix'))]",
		// 							},
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "deny",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("AuditSoonToExpireCerts"),
		// 				Type: to.Ptr("Microsoft.Authorization/policyDefinitions"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/AuditSoonToExpireCerts"),
		// 				Properties: &armpolicy.DefinitionProperties{
		// 					Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."),
		// 					DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"),
		// 					Metadata: map[string]any{
		// 						"category": "KeyVault DataPlane",
		// 					},
		// 					Mode: to.Ptr("Microsoft.KeyVault.Data"),
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 						"daysToExpire": &armpolicy.ParameterDefinitionsValue{
		// 							Type: to.Ptr(armpolicy.ParameterTypeInteger),
		// 							Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
		// 								Description: to.Ptr("The number of days for a certificate to expire."),
		// 								DisplayName: to.Ptr("Days to expire"),
		// 							},
		// 						},
		// 					},
		// 					PolicyRule: map[string]any{
		// 						"if": map[string]any{
		// 							"field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn",
		// 							"lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]",
		// 						},
		// 						"then": map[string]any{
		// 							"effect": "audit",
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeCustom),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

type DefinitionsClientCreateOrUpdateAtManagementGroupOptions added in v0.2.0

type DefinitionsClientCreateOrUpdateAtManagementGroupOptions struct {
}

DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup method.

type DefinitionsClientCreateOrUpdateAtManagementGroupResponse added in v0.2.0

type DefinitionsClientCreateOrUpdateAtManagementGroupResponse struct {
	// The policy definition.
	Definition
}

DefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionsClient.CreateOrUpdateAtManagementGroup.

type DefinitionsClientCreateOrUpdateOptions added in v0.2.0

type DefinitionsClientCreateOrUpdateOptions struct {
}

DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate method.

type DefinitionsClientCreateOrUpdateResponse added in v0.2.0

type DefinitionsClientCreateOrUpdateResponse struct {
	// The policy definition.
	Definition
}

DefinitionsClientCreateOrUpdateResponse contains the response from method DefinitionsClient.CreateOrUpdate.

type DefinitionsClientDeleteAtManagementGroupOptions added in v0.2.0

type DefinitionsClientDeleteAtManagementGroupOptions struct {
}

DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup method.

type DefinitionsClientDeleteAtManagementGroupResponse added in v0.2.0

type DefinitionsClientDeleteAtManagementGroupResponse struct {
}

DefinitionsClientDeleteAtManagementGroupResponse contains the response from method DefinitionsClient.DeleteAtManagementGroup.

type DefinitionsClientDeleteOptions added in v0.2.0

type DefinitionsClientDeleteOptions struct {
}

DefinitionsClientDeleteOptions contains the optional parameters for the DefinitionsClient.Delete method.

type DefinitionsClientDeleteResponse added in v0.2.0

type DefinitionsClientDeleteResponse struct {
}

DefinitionsClientDeleteResponse contains the response from method DefinitionsClient.Delete.

type DefinitionsClientGetAtManagementGroupOptions added in v0.2.0

type DefinitionsClientGetAtManagementGroupOptions struct {
}

DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup method.

type DefinitionsClientGetAtManagementGroupResponse added in v0.2.0

type DefinitionsClientGetAtManagementGroupResponse struct {
	// The policy definition.
	Definition
}

DefinitionsClientGetAtManagementGroupResponse contains the response from method DefinitionsClient.GetAtManagementGroup.

type DefinitionsClientGetBuiltInOptions added in v0.2.0

type DefinitionsClientGetBuiltInOptions struct {
}

DefinitionsClientGetBuiltInOptions contains the optional parameters for the DefinitionsClient.GetBuiltIn method.

type DefinitionsClientGetBuiltInResponse added in v0.2.0

type DefinitionsClientGetBuiltInResponse struct {
	// The policy definition.
	Definition
}

DefinitionsClientGetBuiltInResponse contains the response from method DefinitionsClient.GetBuiltIn.

type DefinitionsClientGetOptions added in v0.2.0

type DefinitionsClientGetOptions struct {
}

DefinitionsClientGetOptions contains the optional parameters for the DefinitionsClient.Get method.

type DefinitionsClientGetResponse added in v0.2.0

type DefinitionsClientGetResponse struct {
	// The policy definition.
	Definition
}

DefinitionsClientGetResponse contains the response from method DefinitionsClient.Get.

type DefinitionsClientListBuiltInOptions added in v0.2.0

type DefinitionsClientListBuiltInOptions struct {
	// The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned
	// list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the
	// returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified,
	// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy
	// definitions whose category match the {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager method.

type DefinitionsClientListBuiltInResponse added in v0.2.0

type DefinitionsClientListBuiltInResponse struct {
	// The response of a PolicyDefinition list operation.
	DefinitionListResult
}

DefinitionsClientListBuiltInResponse contains the response from method DefinitionsClient.NewListBuiltInPager.

type DefinitionsClientListByManagementGroupOptions added in v0.2.0

type DefinitionsClientListByManagementGroupOptions struct {
	// The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned
	// list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the
	// returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified,
	// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy
	// definitions whose category match the {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager method.

type DefinitionsClientListByManagementGroupResponse added in v0.2.0

type DefinitionsClientListByManagementGroupResponse struct {
	// The response of a PolicyDefinition list operation.
	DefinitionListResult
}

DefinitionsClientListByManagementGroupResponse contains the response from method DefinitionsClient.NewListByManagementGroupPager.

type DefinitionsClientListOptions added in v0.2.0

type DefinitionsClientListOptions struct {
	// The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned
	// list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the
	// returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified,
	// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy
	// definitions whose category match the {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.NewListPager method.

type DefinitionsClientListResponse added in v0.2.0

type DefinitionsClientListResponse struct {
	// The response of a PolicyDefinition list operation.
	DefinitionListResult
}

DefinitionsClientListResponse contains the response from method DefinitionsClient.NewListPager.

type EnforcementMode

type EnforcementMode string

EnforcementMode - The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll

const (
	// EnforcementModeDefault - The policy effect is enforced during resource creation or update.
	EnforcementModeDefault EnforcementMode = "Default"
	// EnforcementModeDoNotEnforce - The policy effect is not enforced during resource creation or update.
	EnforcementModeDoNotEnforce EnforcementMode = "DoNotEnforce"
	// EnforcementModeEnroll - The policy effect is not enforced during resource creation or update until the resource or scope
	// of the resource is enrolled to the assignment instance. Enrollment occurs upon deployment of the policy enrollment resource.
	EnforcementModeEnroll EnforcementMode = "Enroll"
)

func PossibleEnforcementModeValues

func PossibleEnforcementModeValues() []EnforcementMode

PossibleEnforcementModeValues returns the possible values for the EnforcementMode const type.

type ExternalEndpointResult added in v1.0.0

type ExternalEndpointResult string

ExternalEndpointResult - The result of the external endpoint. Possible values are Succeeded and Failed.

const (
	// ExternalEndpointResultFailed - The external endpoint failed.
	ExternalEndpointResultFailed ExternalEndpointResult = "Failed"
	// ExternalEndpointResultSucceeded - The external endpoint succeeded.
	ExternalEndpointResultSucceeded ExternalEndpointResult = "Succeeded"
)

func PossibleExternalEndpointResultValues added in v1.0.0

func PossibleExternalEndpointResultValues() []ExternalEndpointResult

PossibleExternalEndpointResultValues returns the possible values for the ExternalEndpointResult const type.

type ExternalEvaluationEndpointInvocationResult added in v1.0.0

type ExternalEvaluationEndpointInvocationResult struct {
	// The set of claims that will be attached to the policy token as an attestation for the result of the endpoint invocation.
	Claims any

	// The expiration of the results.
	Expiration *time.Time

	// The status message with additional details about the invocation result.
	Message *string

	// The details of the policy requiring the external endpoint invocation.
	PolicyInfo *LogInfo

	// The result of the external endpoint. Possible values are Succeeded and Failed.
	Result *ExternalEndpointResult

	// The date and time after which a failed endpoint invocation can be retried.
	RetryAfter *time.Time
}

ExternalEvaluationEndpointInvocationResult - The external evaluation endpoint invocation results.

func (ExternalEvaluationEndpointInvocationResult) MarshalJSON added in v1.0.0

MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEndpointInvocationResult.

func (*ExternalEvaluationEndpointInvocationResult) UnmarshalJSON added in v1.0.0

func (e *ExternalEvaluationEndpointInvocationResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEndpointInvocationResult.

type ExternalEvaluationEndpointSettings added in v1.0.0

type ExternalEvaluationEndpointSettings struct {
	// The details of the endpoint.
	Details any

	// The kind of the endpoint.
	Kind *string
}

ExternalEvaluationEndpointSettings - The settings of an external endpoint providing evaluation results.

func (ExternalEvaluationEndpointSettings) MarshalJSON added in v1.0.0

func (e ExternalEvaluationEndpointSettings) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEndpointSettings.

func (*ExternalEvaluationEndpointSettings) UnmarshalJSON added in v1.0.0

func (e *ExternalEvaluationEndpointSettings) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEndpointSettings.

type ExternalEvaluationEnforcementSettings added in v1.0.0

type ExternalEvaluationEnforcementSettings struct {
	// The settings of an external endpoint providing evaluation results.
	EndpointSettings *ExternalEvaluationEndpointSettings

	// What to do when evaluating an enforcement policy that requires an external evaluation and the token is missing. Possible
	// values are Audit and Deny and language expressions are supported.
	MissingTokenAction *string

	// The lifespan of the endpoint invocation result after which it's no longer valid. Value is expected to follow the ISO 8601
	// duration format and language expressions are supported.
	ResultLifespan *string

	// An array of the role definition Ids the assignment's MSI will need in order to invoke the endpoint.
	RoleDefinitionIDs []*string
}

ExternalEvaluationEnforcementSettings - The details of the source of external evaluation results required by the policy during enforcement evaluation.

func (ExternalEvaluationEnforcementSettings) MarshalJSON added in v1.0.0

func (e ExternalEvaluationEnforcementSettings) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEnforcementSettings.

func (*ExternalEvaluationEnforcementSettings) UnmarshalJSON added in v1.0.0

func (e *ExternalEvaluationEnforcementSettings) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEnforcementSettings.

type Identity

type Identity struct {
	// The identity type. This is the only required field when adding a system or user assigned identity to a resource.
	Type *ResourceIdentityType

	// The user identity associated with the policy. The user identity dictionary key references will be ARM resource ids in the
	// form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
	UserAssignedIdentities map[string]*UserAssignedIdentitiesValue

	// READ-ONLY; The principal ID of the resource identity. This property will only be provided for a system assigned identity
	PrincipalID *string

	// READ-ONLY; The tenant ID of the resource identity. This property will only be provided for a system assigned identity
	TenantID *string
}

Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity.

func (Identity) MarshalJSON

func (i Identity) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Identity.

func (*Identity) UnmarshalJSON added in v0.7.0

func (i *Identity) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Identity.

type LogInfo added in v1.0.0

type LogInfo struct {
	// The management group ancestors.
	Ancestors *string

	// The policy compliance reason code.
	ComplianceReasonCode *string

	// The policy assignment display name.
	PolicyAssignmentDisplayName *string

	// The policy assignment Id.
	PolicyAssignmentID *string

	// The policy assignment name.
	PolicyAssignmentName *string

	// The policy assignment scope.
	PolicyAssignmentScope *string

	// The policy assignment version.
	PolicyAssignmentVersion *string

	// The policy definition display name.
	PolicyDefinitionDisplayName *string

	// The policy definition action.
	PolicyDefinitionEffect *string

	// An array of policy definition group names.
	PolicyDefinitionGroupNames []*string

	// The policy definition Id.
	PolicyDefinitionID *string

	// The policy definition name.
	PolicyDefinitionName *string

	// The policy definition instance Id inside a policy set.
	PolicyDefinitionReferenceID *string

	// The policy definition version.
	PolicyDefinitionVersion *string

	// An array of policy exemption Ids.
	PolicyExemptionIDs []*string

	// The policy set definition category.
	PolicySetDefinitionCategory *string

	// The policy set definition display name.
	PolicySetDefinitionDisplayName *string

	// The policy set definition Id.
	PolicySetDefinitionID *string

	// The policy set definition name.
	PolicySetDefinitionName *string

	// The policy set definition version.
	PolicySetDefinitionVersion *string

	// The resource location.
	ResourceLocation *string
}

LogInfo - The policy log info.

func (LogInfo) MarshalJSON added in v1.0.0

func (l LogInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type LogInfo.

func (*LogInfo) UnmarshalJSON added in v1.0.0

func (l *LogInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type LogInfo.

type NonComplianceMessage

type NonComplianceMessage struct {
	// REQUIRED; A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages
	// and on resource's non-compliant compliance results.
	Message *string

	// The policy definition reference ID within a policy set definition the message is intended for. This is only applicable
	// if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned
	// by this policy assignment.
	PolicyDefinitionReferenceID *string
}

NonComplianceMessage - A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results.

func (NonComplianceMessage) MarshalJSON added in v0.7.0

func (n NonComplianceMessage) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type NonComplianceMessage.

func (*NonComplianceMessage) UnmarshalJSON added in v0.7.0

func (n *NonComplianceMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type NonComplianceMessage.

type Override added in v0.8.0

type Override struct {
	// The override kind.
	Kind *OverrideKind

	// The list of the selector expressions.
	Selectors []*Selector

	// The value to override the policy property.
	Value *string
}

Override - The policy property value override.

func (Override) MarshalJSON added in v0.8.0

func (o Override) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Override.

func (*Override) UnmarshalJSON added in v0.8.0

func (o *Override) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Override.

type OverrideKind added in v0.8.0

type OverrideKind string

OverrideKind - The override kind.

const (
	// OverrideKindDefinitionVersion - It will override the definition version property value of the policy assignment.
	OverrideKindDefinitionVersion OverrideKind = "definitionVersion"
	// OverrideKindPolicyEffect - It will override the policy effect type.
	OverrideKindPolicyEffect OverrideKind = "policyEffect"
)

func PossibleOverrideKindValues added in v0.8.0

func PossibleOverrideKindValues() []OverrideKind

PossibleOverrideKindValues returns the possible values for the OverrideKind const type.

type ParameterDefinitionsValue

type ParameterDefinitionsValue struct {
	// The allowed values for the parameter.
	AllowedValues []any

	// The default value for the parameter if no value is provided.
	DefaultValue any

	// General metadata for the parameter.
	Metadata *ParameterDefinitionsValueMetadata

	// Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported
	// for object-type parameters and follows the Json.NET Schema 2019-09 implementation. You can learn more about using schemas
	// at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/.
	Schema any

	// The data type of the parameter.
	Type *ParameterType
}

ParameterDefinitionsValue - The definition of a parameter that can be provided to the policy.

func (ParameterDefinitionsValue) MarshalJSON

func (p ParameterDefinitionsValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValue.

func (*ParameterDefinitionsValue) UnmarshalJSON added in v0.7.0

func (p *ParameterDefinitionsValue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ParameterDefinitionsValue.

type ParameterDefinitionsValueMetadata

type ParameterDefinitionsValueMetadata struct {
	AdditionalProperties map[string]any

	// Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during
	// policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope.
	AssignPermissions *bool

	// The description of the parameter.
	Description *string

	// The display name for the parameter.
	DisplayName *string

	// Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose
	// from.
	StrongType *string
}

ParameterDefinitionsValueMetadata - General metadata for the parameter.

func (ParameterDefinitionsValueMetadata) MarshalJSON

func (p ParameterDefinitionsValueMetadata) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValueMetadata.

func (*ParameterDefinitionsValueMetadata) UnmarshalJSON

func (p *ParameterDefinitionsValueMetadata) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ParameterDefinitionsValueMetadata.

type ParameterType

type ParameterType string

ParameterType - The data type of the parameter.

const (
	// ParameterTypeArray - The array parameter type.
	ParameterTypeArray ParameterType = "Array"
	// ParameterTypeBoolean - The boolean parameter type.
	ParameterTypeBoolean ParameterType = "Boolean"
	// ParameterTypeDateTime - The date-time parameter type.
	ParameterTypeDateTime ParameterType = "DateTime"
	// ParameterTypeFloat - The float parameter type.
	ParameterTypeFloat ParameterType = "Float"
	// ParameterTypeInteger - The integer parameter type.
	ParameterTypeInteger ParameterType = "Integer"
	// ParameterTypeObject - The object parameter type.
	ParameterTypeObject ParameterType = "Object"
	// ParameterTypeString - The string parameter type.
	ParameterTypeString ParameterType = "String"
)

func PossibleParameterTypeValues

func PossibleParameterTypeValues() []ParameterType

PossibleParameterTypeValues returns the possible values for the ParameterType const type.

type ParameterValuesValue

type ParameterValuesValue struct {
	// The value of the parameter.
	Value any
}

ParameterValuesValue - The value of a parameter.

func (ParameterValuesValue) MarshalJSON added in v0.7.0

func (p ParameterValuesValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ParameterValuesValue.

func (*ParameterValuesValue) UnmarshalJSON added in v0.7.0

func (p *ParameterValuesValue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ParameterValuesValue.

type PolicyTokenResult added in v1.0.0

type PolicyTokenResult string

PolicyTokenResult - The result of the completed token acquisition operation. Possible values are Succeeded and Failed.

const (
	// PolicyTokenResultFailed - The token acquisition failed.
	PolicyTokenResultFailed PolicyTokenResult = "Failed"
	// PolicyTokenResultSucceeded - The token acquisition succeeded.
	PolicyTokenResultSucceeded PolicyTokenResult = "Succeeded"
)

func PossiblePolicyTokenResultValues added in v1.0.0

func PossiblePolicyTokenResultValues() []PolicyTokenResult

PossiblePolicyTokenResultValues returns the possible values for the PolicyTokenResult const type.

type PolicyType

type PolicyType string

PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.

const (
	// PolicyTypeBuiltIn - The built in policy definition type.
	PolicyTypeBuiltIn PolicyType = "BuiltIn"
	// PolicyTypeCustom - The custom policy definition type.
	PolicyTypeCustom PolicyType = "Custom"
	// PolicyTypeNotSpecified - The not specified policy definition type.
	PolicyTypeNotSpecified PolicyType = "NotSpecified"
	// PolicyTypeStatic - The static policy definition type.
	PolicyTypeStatic PolicyType = "Static"
)

func PossiblePolicyTypeValues

func PossiblePolicyTypeValues() []PolicyType

PossiblePolicyTypeValues returns the possible values for the PolicyType const type.

type ResourceIdentityType

type ResourceIdentityType string

ResourceIdentityType - The identity type. This is the only required field when adding a system or user assigned identity to a resource.

const (
	// ResourceIdentityTypeNone - Indicates that no identity is associated with the resource or that the existing identity should
	// be removed.
	ResourceIdentityTypeNone ResourceIdentityType = "None"
	// ResourceIdentityTypeSystemAssigned - Indicates that a system assigned identity is associated with the resource.
	ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned"
	// ResourceIdentityTypeUserAssigned - Indicates that a system assigned identity is associated with the resource.
	ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned"
)

func PossibleResourceIdentityTypeValues

func PossibleResourceIdentityTypeValues() []ResourceIdentityType

PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type.

type ResourceSelector added in v0.8.0

type ResourceSelector struct {
	// The name of the resource selector.
	Name *string

	// The list of the selector expressions.
	Selectors []*Selector
}

ResourceSelector - The resource selector to filter policies by resource properties.

func (ResourceSelector) MarshalJSON added in v0.8.0

func (r ResourceSelector) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ResourceSelector.

func (*ResourceSelector) UnmarshalJSON added in v0.8.0

func (r *ResourceSelector) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ResourceSelector.

type Selector added in v0.8.0

type Selector struct {
	// The list of values to filter in.
	In []*string

	// The selector kind.
	Kind *SelectorKind

	// The list of values to filter out.
	NotIn []*string
}

Selector - The selector expression.

func (Selector) MarshalJSON added in v0.8.0

func (s Selector) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Selector.

func (*Selector) UnmarshalJSON added in v0.8.0

func (s *Selector) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Selector.

type SelectorKind added in v0.8.0

type SelectorKind string

SelectorKind - The selector kind.

const (
	// SelectorKindPolicyDefinitionReferenceID - The selector kind to filter policies by the policy definition reference ID.
	SelectorKindPolicyDefinitionReferenceID SelectorKind = "policyDefinitionReferenceId"
	// SelectorKindResourceLocation - The selector kind to filter policies by the resource location.
	SelectorKindResourceLocation SelectorKind = "resourceLocation"
	// SelectorKindResourceType - The selector kind to filter policies by the resource type.
	SelectorKindResourceType SelectorKind = "resourceType"
	// SelectorKindResourceWithoutLocation - The selector kind to filter policies by the resource without location.
	SelectorKindResourceWithoutLocation SelectorKind = "resourceWithoutLocation"
)

func PossibleSelectorKindValues added in v0.8.0

func PossibleSelectorKindValues() []SelectorKind

PossibleSelectorKindValues returns the possible values for the SelectorKind const type.

type SetDefinition added in v0.2.0

type SetDefinition struct {
	// The policy set definition properties.
	Properties *SetDefinitionProperties

	// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	ID *string

	// READ-ONLY; The name of the resource
	Name *string

	// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData

	// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string
}

SetDefinition - The policy set definition.

func (SetDefinition) MarshalJSON added in v0.7.0

func (s SetDefinition) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SetDefinition.

func (*SetDefinition) UnmarshalJSON added in v0.7.0

func (s *SetDefinition) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinition.

type SetDefinitionListResult added in v0.2.0

type SetDefinitionListResult struct {
	// REQUIRED; The PolicySetDefinition items on this page
	Value []*SetDefinition

	// The link to the next page of items
	NextLink *string
}

SetDefinitionListResult - The response of a PolicySetDefinition list operation.

func (SetDefinitionListResult) MarshalJSON added in v0.2.0

func (s SetDefinitionListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SetDefinitionListResult.

func (*SetDefinitionListResult) UnmarshalJSON added in v0.7.0

func (s *SetDefinitionListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionListResult.

type SetDefinitionProperties added in v0.2.0

type SetDefinitionProperties struct {
	// REQUIRED; An array of policy definition references.
	PolicyDefinitions []*DefinitionReference

	// The policy set definition description.
	Description *string

	// The display name of the policy set definition.
	DisplayName *string

	// The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs.
	Metadata any

	// The policy set definition parameters that can be used in policy definition references.
	Parameters map[string]*ParameterDefinitionsValue

	// The metadata describing groups of policy definition references within the policy set definition.
	PolicyDefinitionGroups []*DefinitionGroup

	// The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.
	PolicyType *PolicyType

	// The policy set definition version in #.#.# format.
	Version *string

	// A list of available versions for this policy set definition.
	Versions []*string
}

SetDefinitionProperties - The policy set definition properties.

func (SetDefinitionProperties) MarshalJSON added in v0.2.0

func (s SetDefinitionProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SetDefinitionProperties.

func (*SetDefinitionProperties) UnmarshalJSON added in v0.7.0

func (s *SetDefinitionProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionProperties.

type SetDefinitionVersion added in v0.10.0

type SetDefinitionVersion struct {
	// The policy set definition version properties.
	Properties *SetDefinitionVersionProperties

	// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	ID *string

	// READ-ONLY; The name of the resource
	Name *string

	// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information.
	SystemData *SystemData

	// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string
}

SetDefinitionVersion - The policy set definition version.

func (SetDefinitionVersion) MarshalJSON added in v0.10.0

func (s SetDefinitionVersion) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersion.

func (*SetDefinitionVersion) UnmarshalJSON added in v0.10.0

func (s *SetDefinitionVersion) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersion.

type SetDefinitionVersionListResult added in v0.10.0

type SetDefinitionVersionListResult struct {
	// REQUIRED; The PolicySetDefinitionVersion items on this page
	Value []*SetDefinitionVersion

	// The link to the next page of items
	NextLink *string
}

SetDefinitionVersionListResult - The response of a PolicySetDefinitionVersion list operation.

func (SetDefinitionVersionListResult) MarshalJSON added in v0.10.0

func (s SetDefinitionVersionListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersionListResult.

func (*SetDefinitionVersionListResult) UnmarshalJSON added in v0.10.0

func (s *SetDefinitionVersionListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersionListResult.

type SetDefinitionVersionProperties added in v0.10.0

type SetDefinitionVersionProperties struct {
	// REQUIRED; An array of policy definition references.
	PolicyDefinitions []*DefinitionReference

	// The policy set definition description.
	Description *string

	// The display name of the policy set definition.
	DisplayName *string

	// The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs.
	Metadata any

	// The policy set definition parameters that can be used in policy definition references.
	Parameters map[string]*ParameterDefinitionsValue

	// The metadata describing groups of policy definition references within the policy set definition.
	PolicyDefinitionGroups []*DefinitionGroup

	// The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.
	PolicyType *PolicyType

	// The policy set definition version in #.#.# format.
	Version *string
}

SetDefinitionVersionProperties - The policy set definition properties.

func (SetDefinitionVersionProperties) MarshalJSON added in v0.10.0

func (s SetDefinitionVersionProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersionProperties.

func (*SetDefinitionVersionProperties) UnmarshalJSON added in v0.10.0

func (s *SetDefinitionVersionProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersionProperties.

type SetDefinitionVersionsClient added in v0.10.0

type SetDefinitionVersionsClient struct {
	// contains filtered or unexported fields
}

SetDefinitionVersionsClient contains the methods for the SetDefinitionVersions group. Don't use this type directly, use NewSetDefinitionVersionsClient() instead.

func NewSetDefinitionVersionsClient added in v0.10.0

func NewSetDefinitionVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionVersionsClient, error)

NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient with the specified values.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - Contains optional client configuration. Pass nil to accept the default values.

func (*SetDefinitionVersionsClient) CreateOrUpdate added in v0.10.0

func (client *SetDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error)

CreateOrUpdate - This operation creates or updates a policy set definition version in the given subscription with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • parameters - The policy set definition properties.
  • options - SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate method.
Example

Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().CreateOrUpdate(ctx, "CostManagement", "1.2.1", armpolicy.SetDefinitionVersion{
		Properties: &armpolicy.SetDefinitionVersionProperties{
			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
			DisplayName: to.Ptr("Cost Management"),
			Metadata: map[string]any{
				"category": "Cost Management",
			},
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"namePrefix": {
					Type:         to.Ptr(armpolicy.ParameterTypeString),
					DefaultValue: "myPrefix",
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						DisplayName: to.Ptr("Prefix to enforce on resource names"),
					},
				},
			},
			PolicyDefinitions: []*armpolicy.DefinitionReference{
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"listOfAllowedSKUs": {
							Value: []any{
								"Standard_GRS",
								"Standard_LRS",
							},
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
				},
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"prefix": {
							Value: "[parameters('namePrefix')]",
						},
						"suffix": {
							Value: "-LC",
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
				},
			},
			Version: to.Ptr("1.2.1"),
		},
	}, 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 = armpolicy.SetDefinitionVersionsClientCreateOrUpdateResponse{
	// 	SetDefinitionVersion: &armpolicy.SetDefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
	// 		Properties: &armpolicy.SetDefinitionVersionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"namePrefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					DefaultValue: "myPrefix",
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						DisplayName: to.Ptr("Prefix to enforce on resource names"),
	// 					},
	// 				},
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "[parameters('namePrefix')]",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) CreateOrUpdateAtManagementGroup added in v0.10.0

func (client *SetDefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)

CreateOrUpdateAtManagementGroup - This operation creates or updates a policy set definition version in the given management group with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • parameters - The policy set definition version properties.
  • options - SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", armpolicy.SetDefinitionVersion{
		Properties: &armpolicy.SetDefinitionVersionProperties{
			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
			DisplayName: to.Ptr("Cost Management"),
			Metadata: map[string]any{
				"category": "Cost Management",
			},
			PolicyDefinitions: []*armpolicy.DefinitionReference{
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"listOfAllowedSKUs": {
							Value: []any{
								"Standard_GRS",
								"Standard_LRS",
							},
						},
					},
					PolicyDefinitionID:          to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
				},
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"prefix": {
							Value: "DeptA",
						},
						"suffix": {
							Value: "-LC",
						},
					},
					PolicyDefinitionID:          to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
				},
			},
			Version: to.Ptr("1.2.1"),
		},
	}, 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 = armpolicy.SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{
	// 	SetDefinitionVersion: &armpolicy.SetDefinitionVersion{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionVersionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) Delete added in v0.10.0

func (client *SetDefinitionVersionsClient) Delete(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error)

Delete - This operation deletes the policy set definition version in the given subscription with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete method.
Example

Generated from example definition: 2025-03-01/deletePolicySetDefinitionVersion.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().Delete(ctx, "CostManagement", "1.2.1", 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 = armpolicy.SetDefinitionVersionsClientDeleteResponse{
	// }
}

func (*SetDefinitionVersionsClient) DeleteAtManagementGroup added in v0.10.0

func (client *SetDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error)

DeleteAtManagementGroup - This operation deletes the policy set definition version in the given management group with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", 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 = armpolicy.SetDefinitionVersionsClientDeleteAtManagementGroupResponse{
	// }
}

func (*SetDefinitionVersionsClient) Get added in v0.10.0

func (client *SetDefinitionVersionsClient) Get(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error)

Get - This operation retrieves the policy set definition version in the given subscription with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get method.
Example

Generated from example definition: 2025-03-01/getPolicySetDefinitionVersion.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().Get(ctx, "CostManagement", "1.2.1", 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 = armpolicy.SetDefinitionVersionsClientGetResponse{
	// 	SetDefinitionVersion: &armpolicy.SetDefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
	// 		Properties: &armpolicy.SetDefinitionVersionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{
	// 				{
	// 					Name: to.Ptr("CostSaving"),
	// 					Description: to.Ptr("Policies designed to control spend within a subscription."),
	// 					DisplayName: to.Ptr("Cost Management Policies"),
	// 				},
	// 				{
	// 					Name: to.Ptr("Organizational"),
	// 					Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."),
	// 					DisplayName: to.Ptr("Organizational Policies"),
	// 				},
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("CostSaving"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("Organizational"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) GetAtManagementGroup added in v0.10.0

func (client *SetDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error)

GetAtManagementGroup - This operation retrieves the policy set definition version in the given management group with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", 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 = armpolicy.SetDefinitionVersionsClientGetAtManagementGroupResponse{
	// 	SetDefinitionVersion: &armpolicy.SetDefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
	// 		Properties: &armpolicy.SetDefinitionVersionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) GetBuiltIn added in v0.10.0

func (client *SetDefinitionVersionsClient) GetBuiltIn(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetBuiltInOptions) (SetDefinitionVersionsClientGetBuiltInResponse, error)

GetBuiltIn - This operation retrieves the built-in policy set definition version with the given name and version. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition.
  • policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y is the minor version number, and z is the patch number
  • options - SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn method.
Example

Generated from example definition: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().GetBuiltIn(ctx, "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", "1.2.1", 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 = armpolicy.SetDefinitionVersionsClientGetBuiltInResponse{
	// 	SetDefinitionVersion: &armpolicy.SetDefinitionVersion{
	// 		Name: to.Ptr("1.2.1"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 		ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versions/1.2.1"),
	// 		Properties: &armpolicy.SetDefinitionVersionProperties{
	// 			Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
	// 			DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
	// 			Metadata: map[string]any{
	// 				"category": "Security Center",
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId1"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId2"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId3"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId4"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId5"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId6"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId7"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId8"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId9"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId10"),
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 			Version: to.Ptr("1.2.1"),
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) ListAll added in v0.10.0

ListAll - Lists all policy set definition versions within a subscription.

This operation lists all the policy set definition versions for all policy set definitions within a subscription. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • options - SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll method.
Example

Generated from example definition: 2025-03-01/listAllPolicySetDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().ListAll(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 = armpolicy.SetDefinitionVersionsClientListAllResponse{
	// 	SetDefinitionVersionListResult: &armpolicy.SetDefinitionVersionListResult{
	// 		Value: []*armpolicy.SetDefinitionVersion{
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
	// 				Properties: &armpolicy.SetDefinitionVersionProperties{
	// 					Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 					DisplayName: to.Ptr("Cost Management"),
	// 					Metadata: map[string]any{
	// 						"category": "Cost Management",
	// 					},
	// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 								"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 									Value: []any{
	// 										"Standard_GRS",
	// 										"Standard_LRS",
	// 									},
	// 								},
	// 							},
	// 							PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 							PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 								"prefix": &armpolicy.ParameterValuesValue{
	// 									Value: "DeptA",
	// 								},
	// 								"suffix": &armpolicy.ParameterValuesValue{
	// 									Value: "-LC",
	// 								},
	// 							},
	// 							PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 							PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 						},
	// 					},
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) ListAllAtManagementGroup added in v0.10.0

ListAllAtManagementGroup - Lists all policy set definition versions at management group scope.

This operation lists all the policy set definition versions for all policy set definitions at the management group scope. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • options - SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().ListAllAtManagementGroup(ctx, "MyManagementGroup", 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 = armpolicy.SetDefinitionVersionsClientListAllAtManagementGroupResponse{
	// 	SetDefinitionVersionListResult: &armpolicy.SetDefinitionVersionListResult{
	// 		Value: []*armpolicy.SetDefinitionVersion{
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versoins/1.2.1"),
	// 				Properties: &armpolicy.SetDefinitionVersionProperties{
	// 					Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
	// 					DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
	// 					Metadata: map[string]any{
	// 						"category": "Security Center",
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 					},
	// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId1"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId2"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId3"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId4"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId5"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId6"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId7"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId8"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId9"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId10"),
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
	// 				Properties: &armpolicy.SetDefinitionVersionProperties{
	// 					Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 					DisplayName: to.Ptr("Cost Management"),
	// 					Metadata: map[string]any{
	// 						"category": "Cost Management",
	// 					},
	// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 								"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 									Value: []any{
	// 										"Standard_GRS",
	// 										"Standard_LRS",
	// 									},
	// 								},
	// 							},
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 							PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 								"prefix": &armpolicy.ParameterValuesValue{
	// 									Value: "DeptA",
	// 								},
	// 								"suffix": &armpolicy.ParameterValuesValue{
	// 									Value: "-LC",
	// 								},
	// 							},
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 							PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 						},
	// 					},
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) ListAllBuiltins added in v0.10.0

ListAllBuiltins - Lists all built-in policy set definition versions.

This operation lists all the built-in policy set definition versions for all built-in policy set definitions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • options - SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins method.
Example

Generated from example definition: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionVersionsClient().ListAllBuiltins(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 = armpolicy.SetDefinitionVersionsClientListAllBuiltinsResponse{
	// 	SetDefinitionVersionListResult: &armpolicy.SetDefinitionVersionListResult{
	// 		Value: []*armpolicy.SetDefinitionVersion{
	// 			{
	// 				Name: to.Ptr("1.2.1"),
	// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
	// 				ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versions/1.2.1"),
	// 				Properties: &armpolicy.SetDefinitionVersionProperties{
	// 					Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
	// 					DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
	// 					Metadata: map[string]any{
	// 						"category": "Security Center",
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 					},
	// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId1"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId2"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId3"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId4"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId5"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId6"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId7"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId8"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId9"),
	// 						},
	// 						{
	// 							DefinitionVersion: to.Ptr("1.*.*"),
	// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
	// 							PolicyDefinitionReferenceID: to.Ptr("RefId10"),
	// 						},
	// 					},
	// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 					Version: to.Ptr("1.2.1"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionVersionsClient) NewListBuiltInPager added in v0.10.0

NewListBuiltInPager - This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition.
  • options - SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager method.
Example

Generated from example definition: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSetDefinitionVersionsClient().NewListBuiltInPager("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", 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 = armpolicy.SetDefinitionVersionsClientListBuiltInResponse{
		// 	SetDefinitionVersionListResult: armpolicy.SetDefinitionVersionListResult{
		// 		Value: []*armpolicy.SetDefinitionVersion{
		// 			{
		// 				Name: to.Ptr("1.2.1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versions/1.2.1"),
		// 				Properties: &armpolicy.SetDefinitionVersionProperties{
		// 					Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
		// 					DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
		// 					Metadata: map[string]any{
		// 						"category": "Security Center",
		// 					},
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId1"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId2"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId3"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId4"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId5"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId6"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId7"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId8"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId9"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId10"),
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*SetDefinitionVersionsClient) NewListByManagementGroupPager added in v0.10.0

func (client *SetDefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, policySetDefinitionName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse]

NewListByManagementGroupPager - This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • policySetDefinitionName - The name of the policy set definition.
  • options - SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager method.
Example

Generated from example definition: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSetDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "CostManagement", 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 = armpolicy.SetDefinitionVersionsClientListByManagementGroupResponse{
		// 	SetDefinitionVersionListResult: armpolicy.SetDefinitionVersionListResult{
		// 		Value: []*armpolicy.SetDefinitionVersion{
		// 			{
		// 				Name: to.Ptr("1.2.1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
		// 				Properties: &armpolicy.SetDefinitionVersionProperties{
		// 					Description: to.Ptr("Policies to enforce low cost storage SKUs"),
		// 					DisplayName: to.Ptr("Cost Management"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
		// 									Value: []any{
		// 										"Standard_GRS",
		// 										"Standard_LRS",
		// 									},
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"prefix": &armpolicy.ParameterValuesValue{
		// 									Value: "DeptA",
		// 								},
		// 								"suffix": &armpolicy.ParameterValuesValue{
		// 									Value: "-LC",
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
		// 						},
		// 					},
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*SetDefinitionVersionsClient) NewListPager added in v0.10.0

NewListPager - This operation retrieves a list of all the policy set definition versions for the given policy set definition.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition.
  • options - SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager method.
Example

Generated from example definition: 2025-03-01/listPolicySetDefinitionVersions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSetDefinitionVersionsClient().NewListPager("CostManagement", 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 = armpolicy.SetDefinitionVersionsClientListResponse{
		// 	SetDefinitionVersionListResult: armpolicy.SetDefinitionVersionListResult{
		// 		Value: []*armpolicy.SetDefinitionVersion{
		// 			{
		// 				Name: to.Ptr("1.2.1"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"),
		// 				Properties: &armpolicy.SetDefinitionVersionProperties{
		// 					Description: to.Ptr("Policies to enforce low cost storage SKUs"),
		// 					DisplayName: to.Ptr("Cost Management"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
		// 									Value: []any{
		// 										"Standard_GRS",
		// 										"Standard_LRS",
		// 									},
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"prefix": &armpolicy.ParameterValuesValue{
		// 									Value: "DeptA",
		// 								},
		// 								"suffix": &armpolicy.ParameterValuesValue{
		// 									Value: "-LC",
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
		// 						},
		// 					},
		// 					Version: to.Ptr("1.2.1"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions added in v0.10.0

type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct {
}

SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup method.

type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse added in v0.10.0

type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct {
	// The policy set definition version.
	SetDefinitionVersion
}

SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup.

type SetDefinitionVersionsClientCreateOrUpdateOptions added in v0.10.0

type SetDefinitionVersionsClientCreateOrUpdateOptions struct {
}

SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate method.

type SetDefinitionVersionsClientCreateOrUpdateResponse added in v0.10.0

type SetDefinitionVersionsClientCreateOrUpdateResponse struct {
	// The policy set definition version.
	SetDefinitionVersion
}

SetDefinitionVersionsClientCreateOrUpdateResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdate.

type SetDefinitionVersionsClientDeleteAtManagementGroupOptions added in v0.10.0

type SetDefinitionVersionsClientDeleteAtManagementGroupOptions struct {
}

SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup method.

type SetDefinitionVersionsClientDeleteAtManagementGroupResponse added in v0.10.0

type SetDefinitionVersionsClientDeleteAtManagementGroupResponse struct {
}

SetDefinitionVersionsClientDeleteAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.DeleteAtManagementGroup.

type SetDefinitionVersionsClientDeleteOptions added in v0.10.0

type SetDefinitionVersionsClientDeleteOptions struct {
}

SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete method.

type SetDefinitionVersionsClientDeleteResponse added in v0.10.0

type SetDefinitionVersionsClientDeleteResponse struct {
}

SetDefinitionVersionsClientDeleteResponse contains the response from method SetDefinitionVersionsClient.Delete.

type SetDefinitionVersionsClientGetAtManagementGroupOptions added in v0.10.0

type SetDefinitionVersionsClientGetAtManagementGroupOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup method.

type SetDefinitionVersionsClientGetAtManagementGroupResponse added in v0.10.0

type SetDefinitionVersionsClientGetAtManagementGroupResponse struct {
	// The policy set definition version.
	SetDefinitionVersion
}

SetDefinitionVersionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.GetAtManagementGroup.

type SetDefinitionVersionsClientGetBuiltInOptions added in v0.10.0

type SetDefinitionVersionsClientGetBuiltInOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn method.

type SetDefinitionVersionsClientGetBuiltInResponse added in v0.10.0

type SetDefinitionVersionsClientGetBuiltInResponse struct {
	// The policy set definition version.
	SetDefinitionVersion
}

SetDefinitionVersionsClientGetBuiltInResponse contains the response from method SetDefinitionVersionsClient.GetBuiltIn.

type SetDefinitionVersionsClientGetOptions added in v0.10.0

type SetDefinitionVersionsClientGetOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get method.

type SetDefinitionVersionsClientGetResponse added in v0.10.0

type SetDefinitionVersionsClientGetResponse struct {
	// The policy set definition version.
	SetDefinitionVersion
}

SetDefinitionVersionsClientGetResponse contains the response from method SetDefinitionVersionsClient.Get.

type SetDefinitionVersionsClientListAllAtManagementGroupOptions added in v0.10.0

type SetDefinitionVersionsClientListAllAtManagementGroupOptions struct {
}

SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup method.

type SetDefinitionVersionsClientListAllAtManagementGroupResponse added in v0.10.0

type SetDefinitionVersionsClientListAllAtManagementGroupResponse struct {
	// The response of a PolicySetDefinitionVersion list operation.
	SetDefinitionVersionListResult
}

SetDefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.ListAllAtManagementGroup.

type SetDefinitionVersionsClientListAllBuiltinsOptions added in v0.10.0

type SetDefinitionVersionsClientListAllBuiltinsOptions struct {
}

SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins method.

type SetDefinitionVersionsClientListAllBuiltinsResponse added in v0.10.0

type SetDefinitionVersionsClientListAllBuiltinsResponse struct {
	// The response of a PolicySetDefinitionVersion list operation.
	SetDefinitionVersionListResult
}

SetDefinitionVersionsClientListAllBuiltinsResponse contains the response from method SetDefinitionVersionsClient.ListAllBuiltins.

type SetDefinitionVersionsClientListAllOptions added in v0.10.0

type SetDefinitionVersionsClientListAllOptions struct {
}

SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll method.

type SetDefinitionVersionsClientListAllResponse added in v0.10.0

type SetDefinitionVersionsClientListAllResponse struct {
	// The response of a PolicySetDefinitionVersion list operation.
	SetDefinitionVersionListResult
}

SetDefinitionVersionsClientListAllResponse contains the response from method SetDefinitionVersionsClient.ListAll.

type SetDefinitionVersionsClientListBuiltInOptions added in v0.10.0

type SetDefinitionVersionsClientListBuiltInOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager method.

type SetDefinitionVersionsClientListBuiltInResponse added in v0.10.0

type SetDefinitionVersionsClientListBuiltInResponse struct {
	// The response of a PolicySetDefinitionVersion list operation.
	SetDefinitionVersionListResult
}

SetDefinitionVersionsClientListBuiltInResponse contains the response from method SetDefinitionVersionsClient.NewListBuiltInPager.

type SetDefinitionVersionsClientListByManagementGroupOptions added in v0.10.0

type SetDefinitionVersionsClientListByManagementGroupOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager method.

type SetDefinitionVersionsClientListByManagementGroupResponse added in v0.10.0

type SetDefinitionVersionsClientListByManagementGroupResponse struct {
	// The response of a PolicySetDefinitionVersion list operation.
	SetDefinitionVersionListResult
}

SetDefinitionVersionsClientListByManagementGroupResponse contains the response from method SetDefinitionVersionsClient.NewListByManagementGroupPager.

type SetDefinitionVersionsClientListOptions added in v0.10.0

type SetDefinitionVersionsClientListOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager method.

type SetDefinitionVersionsClientListResponse added in v0.10.0

type SetDefinitionVersionsClientListResponse struct {
	// The response of a PolicySetDefinitionVersion list operation.
	SetDefinitionVersionListResult
}

SetDefinitionVersionsClientListResponse contains the response from method SetDefinitionVersionsClient.NewListPager.

type SetDefinitionsClient added in v0.2.0

type SetDefinitionsClient struct {
	// contains filtered or unexported fields
}

SetDefinitionsClient contains the methods for the SetDefinitions group. Don't use this type directly, use NewSetDefinitionsClient() instead.

func NewSetDefinitionsClient added in v0.2.0

func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionsClient, error)

NewSetDefinitionsClient creates a new instance of SetDefinitionsClient with the specified values.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - Contains optional client configuration. Pass nil to accept the default values.

func (*SetDefinitionsClient) CreateOrUpdate added in v0.2.0

func (client *SetDefinitionsClient) CreateOrUpdate(ctx context.Context, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateOptions) (SetDefinitionsClientCreateOrUpdateResponse, error)

CreateOrUpdate - This operation creates or updates a policy set definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition to get.
  • parameters - The policy set definition properties.
  • options - SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate method.
Example (CreateOrUpdateAPolicySetDefinition)

Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinition.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{
		Properties: &armpolicy.SetDefinitionProperties{
			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
			DisplayName: to.Ptr("Cost Management"),
			Metadata: map[string]any{
				"category": "Cost Management",
			},
			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
				"namePrefix": {
					Type:         to.Ptr(armpolicy.ParameterTypeString),
					DefaultValue: "myPrefix",
					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
						DisplayName: to.Ptr("Prefix to enforce on resource names"),
					},
				},
			},
			PolicyDefinitions: []*armpolicy.DefinitionReference{
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"listOfAllowedSKUs": {
							Value: []any{
								"Standard_GRS",
								"Standard_LRS",
							},
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
				},
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"prefix": {
							Value: "[parameters('namePrefix')]",
						},
						"suffix": {
							Value: "-LC",
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
				},
			},
		},
	}, 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 = armpolicy.SetDefinitionsClientCreateOrUpdateResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 				"namePrefix": &armpolicy.ParameterDefinitionsValue{
	// 					Type: to.Ptr(armpolicy.ParameterTypeString),
	// 					DefaultValue: "myPrefix",
	// 					Metadata: &armpolicy.ParameterDefinitionsValueMetadata{
	// 						DisplayName: to.Ptr("Prefix to enforce on resource names"),
	// 					},
	// 				},
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "[parameters('namePrefix')]",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}
Example (CreateOrUpdateAPolicySetDefinitionWithGroups)

Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroups.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{
		Properties: &armpolicy.SetDefinitionProperties{
			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
			DisplayName: to.Ptr("Cost Management"),
			Metadata: map[string]any{
				"category": "Cost Management",
			},
			PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{
				{
					Name:        to.Ptr("CostSaving"),
					Description: to.Ptr("Policies designed to control spend within a subscription."),
					DisplayName: to.Ptr("Cost Management Policies"),
				},
				{
					Name:        to.Ptr("Organizational"),
					Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."),
					DisplayName: to.Ptr("Organizational Policies"),
				},
			},
			PolicyDefinitions: []*armpolicy.DefinitionReference{
				{
					DefinitionVersion: to.Ptr("1.*.*"),
					GroupNames: []*string{
						to.Ptr("CostSaving"),
					},
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"listOfAllowedSKUs": {
							Value: []any{
								"Standard_GRS",
								"Standard_LRS",
							},
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
				},
				{
					DefinitionVersion: to.Ptr("1.*.*"),
					GroupNames: []*string{
						to.Ptr("Organizational"),
					},
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"prefix": {
							Value: "DeptA",
						},
						"suffix": {
							Value: "-LC",
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
				},
			},
		},
	}, 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 = armpolicy.SetDefinitionsClientCreateOrUpdateResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{
	// 				{
	// 					Name: to.Ptr("CostSaving"),
	// 					Description: to.Ptr("Policies designed to control spend within a subscription."),
	// 					DisplayName: to.Ptr("Cost Management Policies"),
	// 				},
	// 				{
	// 					Name: to.Ptr("Organizational"),
	// 					Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."),
	// 					DisplayName: to.Ptr("Organizational Policies"),
	// 				},
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("CostSaving"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("Organizational"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionsClient) CreateOrUpdateAtManagementGroup added in v0.2.0

func (client *SetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse, error)

CreateOrUpdateAtManagementGroup - This operation creates or updates a policy set definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • policySetDefinitionName - The name of the policy set definition to get.
  • parameters - The policy set definition properties.
  • options - SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup method.
Example (CreateOrUpdateAPolicySetDefinitionAtManagementGroupLevel)

Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", armpolicy.SetDefinition{
		Properties: &armpolicy.SetDefinitionProperties{
			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
			DisplayName: to.Ptr("Cost Management"),
			Metadata: map[string]any{
				"category": "Cost Management",
			},
			PolicyDefinitions: []*armpolicy.DefinitionReference{
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"listOfAllowedSKUs": {
							Value: []any{
								"Standard_GRS",
								"Standard_LRS",
							},
						},
					},
					PolicyDefinitionID:          to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
				},
				{
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"prefix": {
							Value: "DeptA",
						},
						"suffix": {
							Value: "-LC",
						},
					},
					PolicyDefinitionID:          to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
				},
			},
		},
	}, 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 = armpolicy.SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}
Example (CreateOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel)

Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", armpolicy.SetDefinition{
		Properties: &armpolicy.SetDefinitionProperties{
			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
			DisplayName: to.Ptr("Cost Management"),
			Metadata: map[string]any{
				"category": "Cost Management",
			},
			PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{
				{
					Name:        to.Ptr("CostSaving"),
					Description: to.Ptr("Policies designed to control spend within a subscription."),
					DisplayName: to.Ptr("Cost Management Policies"),
				},
				{
					Name:        to.Ptr("Organizational"),
					Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."),
					DisplayName: to.Ptr("Organizational Policies"),
				},
			},
			PolicyDefinitions: []*armpolicy.DefinitionReference{
				{
					GroupNames: []*string{
						to.Ptr("CostSaving"),
					},
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"listOfAllowedSKUs": {
							Value: []any{
								"Standard_GRS",
								"Standard_LRS",
							},
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
				},
				{
					GroupNames: []*string{
						to.Ptr("Organizational"),
					},
					Parameters: map[string]*armpolicy.ParameterValuesValue{
						"prefix": {
							Value: "DeptA",
						},
						"suffix": {
							Value: "-LC",
						},
					},
					PolicyDefinitionID:          to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
				},
			},
		},
	}, 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 = armpolicy.SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{
	// 				{
	// 					Name: to.Ptr("CostSaving"),
	// 					Description: to.Ptr("Policies designed to control spend within a subscription."),
	// 					DisplayName: to.Ptr("Cost Management Policies"),
	// 				},
	// 				{
	// 					Name: to.Ptr("Organizational"),
	// 					Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."),
	// 					DisplayName: to.Ptr("Organizational Policies"),
	// 				},
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("CostSaving"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("Organizational"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionsClient) Delete added in v0.2.0

Delete - This operation deletes the policy set definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition to get.
  • options - SetDefinitionsClientDeleteOptions contains the optional parameters for the SetDefinitionsClient.Delete method.
Example

Generated from example definition: 2025-03-01/deletePolicySetDefinition.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().Delete(ctx, "CostManagement", 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 = armpolicy.SetDefinitionsClientDeleteResponse{
	// }
}

func (*SetDefinitionsClient) DeleteAtManagementGroup added in v0.2.0

func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (SetDefinitionsClientDeleteAtManagementGroupResponse, error)

DeleteAtManagementGroup - This operation deletes the policy set definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • policySetDefinitionName - The name of the policy set definition to get.
  • options - SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", 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 = armpolicy.SetDefinitionsClientDeleteAtManagementGroupResponse{
	// }
}

func (*SetDefinitionsClient) Get added in v0.2.0

Get - This operation retrieves the policy set definition in the given subscription with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition to get.
  • options - SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method.
Example

Generated from example definition: 2025-03-01/getPolicySetDefinition.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().Get(ctx, "CostManagement", 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 = armpolicy.SetDefinitionsClientGetResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{
	// 				{
	// 					Name: to.Ptr("CostSaving"),
	// 					Description: to.Ptr("Policies designed to control spend within a subscription."),
	// 					DisplayName: to.Ptr("Cost Management Policies"),
	// 				},
	// 				{
	// 					Name: to.Ptr("Organizational"),
	// 					Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."),
	// 					DisplayName: to.Ptr("Organizational Policies"),
	// 				},
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("CostSaving"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					GroupNames: []*string{
	// 						to.Ptr("Organizational"),
	// 					},
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionsClient) GetAtManagementGroup added in v0.2.0

func (client *SetDefinitionsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientGetAtManagementGroupOptions) (SetDefinitionsClientGetAtManagementGroupResponse, error)

GetAtManagementGroup - This operation retrieves the policy set definition in the given management group with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • policySetDefinitionName - The name of the policy set definition to get.
  • options - SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", 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 = armpolicy.SetDefinitionsClientGetAtManagementGroupResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("CostManagement"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Policies to enforce low cost storage SKUs"),
	// 			DisplayName: to.Ptr("Cost Management"),
	// 			Metadata: map[string]any{
	// 				"category": "Cost Management",
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
	// 							Value: []any{
	// 								"Standard_GRS",
	// 								"Standard_LRS",
	// 							},
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					Parameters: map[string]*armpolicy.ParameterValuesValue{
	// 						"prefix": &armpolicy.ParameterValuesValue{
	// 							Value: "DeptA",
	// 						},
	// 						"suffix": &armpolicy.ParameterValuesValue{
	// 							Value: "-LC",
	// 						},
	// 					},
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
	// 					PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
	// 				},
	// 			},
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionsClient) GetBuiltIn added in v0.2.0

GetBuiltIn - This operation retrieves the built-in policy set definition with the given name. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • policySetDefinitionName - The name of the policy set definition to get.
  • options - SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn method.
Example

Generated from example definition: 2025-03-01/getBuiltInPolicySetDefinition.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSetDefinitionsClient().GetBuiltIn(ctx, "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", 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 = armpolicy.SetDefinitionsClientGetBuiltInResponse{
	// 	SetDefinition: &armpolicy.SetDefinition{
	// 		Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
	// 		Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
	// 		ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
	// 		Properties: &armpolicy.SetDefinitionProperties{
	// 			Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
	// 			DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
	// 			Metadata: map[string]any{
	// 				"category": "Security Center",
	// 			},
	// 			Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
	// 			},
	// 			PolicyDefinitions: []*armpolicy.DefinitionReference{
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId1"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId2"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId3"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId4"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId5"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId6"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId7"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId8"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId9"),
	// 				},
	// 				{
	// 					DefinitionVersion: to.Ptr("1.*.*"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
	// 					PolicyDefinitionReferenceID: to.Ptr("RefId10"),
	// 				},
	// 			},
	// 			PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
	// 			Version: to.Ptr("1.2.1"),
	// 			Versions: []*string{
	// 				to.Ptr("1.2.1"),
	// 				to.Ptr("1.0.0"),
	// 			},
	// 		},
	// 	},
	// }
}

func (*SetDefinitionsClient) NewListBuiltInPager added in v0.5.0

NewListBuiltInPager - This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}.

Generated from API version 2025-03-01

  • options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager method.
Example

Generated from example definition: 2025-03-01/listBuiltInPolicySetDefinitions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSetDefinitionsClient().NewListBuiltInPager(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 = armpolicy.SetDefinitionsClientListBuiltInResponse{
		// 	SetDefinitionListResult: armpolicy.SetDefinitionListResult{
		// 		Value: []*armpolicy.SetDefinition{
		// 			{
		// 				Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
		// 				Properties: &armpolicy.SetDefinitionProperties{
		// 					Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
		// 					DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
		// 					Metadata: map[string]any{
		// 						"category": "Security Center",
		// 					},
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId1"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId2"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId3"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId4"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId5"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId6"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId7"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId8"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId9"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId10"),
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*SetDefinitionsClient) NewListByManagementGroupPager added in v0.5.0

NewListByManagementGroupPager - This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}”. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}.

Generated from API version 2025-03-01

  • managementGroupID - The ID of the management group.
  • options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager method.
Example

Generated from example definition: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSetDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", 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 = armpolicy.SetDefinitionsClientListByManagementGroupResponse{
		// 	SetDefinitionListResult: armpolicy.SetDefinitionListResult{
		// 		Value: []*armpolicy.SetDefinition{
		// 			{
		// 				Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
		// 				Properties: &armpolicy.SetDefinitionProperties{
		// 					Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
		// 					DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
		// 					Metadata: map[string]any{
		// 						"category": "Security Center",
		// 					},
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId1"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId2"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId3"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId4"),
		// 						},
		// 						{
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId5"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId6"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId7"),
		// 						},
		// 						{
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId8"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId9"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId10"),
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("CostManagement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
		// 				Properties: &armpolicy.SetDefinitionProperties{
		// 					Description: to.Ptr("Policies to enforce low cost storage SKUs"),
		// 					DisplayName: to.Ptr("Cost Management"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
		// 									Value: []any{
		// 										"Standard_GRS",
		// 										"Standard_LRS",
		// 									},
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"prefix": &armpolicy.ParameterValuesValue{
		// 									Value: "DeptA",
		// 								},
		// 								"suffix": &armpolicy.ParameterValuesValue{
		// 									Value: "-LC",
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
		// 						},
		// 					},
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

func (*SetDefinitionsClient) NewListPager added in v0.5.0

NewListPager - This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}”. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}.

Generated from API version 2025-03-01

  • options - SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method.
Example

Generated from example definition: 2025-03-01/listPolicySetDefinitions.json

package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSetDefinitionsClient().NewListPager(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 = armpolicy.SetDefinitionsClientListResponse{
		// 	SetDefinitionListResult: armpolicy.SetDefinitionListResult{
		// 		Value: []*armpolicy.SetDefinition{
		// 			{
		// 				Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
		// 				ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"),
		// 				Properties: &armpolicy.SetDefinitionProperties{
		// 					Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."),
		// 					DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"),
		// 					Metadata: map[string]any{
		// 						"category": "Security Center",
		// 					},
		// 					Parameters: map[string]*armpolicy.ParameterDefinitionsValue{
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId1"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId2"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId3"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId4"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId5"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId6"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId7"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId8"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId9"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"),
		// 							PolicyDefinitionReferenceID: to.Ptr("RefId10"),
		// 						},
		// 					},
		// 					PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn),
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("CostManagement"),
		// 				Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"),
		// 				ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
		// 				Properties: &armpolicy.SetDefinitionProperties{
		// 					Description: to.Ptr("Policies to enforce low cost storage SKUs"),
		// 					DisplayName: to.Ptr("Cost Management"),
		// 					Metadata: map[string]any{
		// 						"category": "Cost Management",
		// 					},
		// 					PolicyDefinitions: []*armpolicy.DefinitionReference{
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"listOfAllowedSKUs": &armpolicy.ParameterValuesValue{
		// 									Value: []any{
		// 										"Standard_GRS",
		// 										"Standard_LRS",
		// 									},
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"),
		// 						},
		// 						{
		// 							DefinitionVersion: to.Ptr("1.*.*"),
		// 							Parameters: map[string]*armpolicy.ParameterValuesValue{
		// 								"prefix": &armpolicy.ParameterValuesValue{
		// 									Value: "DeptA",
		// 								},
		// 								"suffix": &armpolicy.ParameterValuesValue{
		// 									Value: "-LC",
		// 								},
		// 							},
		// 							PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
		// 							PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"),
		// 						},
		// 					},
		// 					Version: to.Ptr("1.2.1"),
		// 					Versions: []*string{
		// 						to.Ptr("1.2.1"),
		// 						to.Ptr("1.0.0"),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

type SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions added in v0.2.0

type SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions struct {
}

SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup method.

type SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse added in v0.2.0

type SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse struct {
	// The policy set definition.
	SetDefinition
}

SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionsClient.CreateOrUpdateAtManagementGroup.

type SetDefinitionsClientCreateOrUpdateOptions added in v0.2.0

type SetDefinitionsClientCreateOrUpdateOptions struct {
}

SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate method.

type SetDefinitionsClientCreateOrUpdateResponse added in v0.2.0

type SetDefinitionsClientCreateOrUpdateResponse struct {
	// The policy set definition.
	SetDefinition
}

SetDefinitionsClientCreateOrUpdateResponse contains the response from method SetDefinitionsClient.CreateOrUpdate.

type SetDefinitionsClientDeleteAtManagementGroupOptions added in v0.2.0

type SetDefinitionsClientDeleteAtManagementGroupOptions struct {
}

SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup method.

type SetDefinitionsClientDeleteAtManagementGroupResponse added in v0.2.0

type SetDefinitionsClientDeleteAtManagementGroupResponse struct {
}

SetDefinitionsClientDeleteAtManagementGroupResponse contains the response from method SetDefinitionsClient.DeleteAtManagementGroup.

type SetDefinitionsClientDeleteOptions added in v0.2.0

type SetDefinitionsClientDeleteOptions struct {
}

SetDefinitionsClientDeleteOptions contains the optional parameters for the SetDefinitionsClient.Delete method.

type SetDefinitionsClientDeleteResponse added in v0.2.0

type SetDefinitionsClientDeleteResponse struct {
}

SetDefinitionsClientDeleteResponse contains the response from method SetDefinitionsClient.Delete.

type SetDefinitionsClientGetAtManagementGroupOptions added in v0.2.0

type SetDefinitionsClientGetAtManagementGroupOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup method.

type SetDefinitionsClientGetAtManagementGroupResponse added in v0.2.0

type SetDefinitionsClientGetAtManagementGroupResponse struct {
	// The policy set definition.
	SetDefinition
}

SetDefinitionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionsClient.GetAtManagementGroup.

type SetDefinitionsClientGetBuiltInOptions added in v0.2.0

type SetDefinitionsClientGetBuiltInOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn method.

type SetDefinitionsClientGetBuiltInResponse added in v0.2.0

type SetDefinitionsClientGetBuiltInResponse struct {
	// The policy set definition.
	SetDefinition
}

SetDefinitionsClientGetBuiltInResponse contains the response from method SetDefinitionsClient.GetBuiltIn.

type SetDefinitionsClientGetOptions added in v0.2.0

type SetDefinitionsClientGetOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string
}

SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method.

type SetDefinitionsClientGetResponse added in v0.2.0

type SetDefinitionsClientGetResponse struct {
	// The policy set definition.
	SetDefinition
}

SetDefinitionsClientGetResponse contains the response from method SetDefinitionsClient.Get.

type SetDefinitionsClientListBuiltInOptions added in v0.2.0

type SetDefinitionsClientListBuiltInOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned
	// list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided,
	// the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are
	// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes
	// all policy set definitions whose category match the {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager method.

type SetDefinitionsClientListBuiltInResponse added in v0.2.0

type SetDefinitionsClientListBuiltInResponse struct {
	// The response of a PolicySetDefinition list operation.
	SetDefinitionListResult
}

SetDefinitionsClientListBuiltInResponse contains the response from method SetDefinitionsClient.NewListBuiltInPager.

type SetDefinitionsClientListByManagementGroupOptions added in v0.2.0

type SetDefinitionsClientListByManagementGroupOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned
	// list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided,
	// the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are
	// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes
	// all policy set definitions whose category match the {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager method.

type SetDefinitionsClientListByManagementGroupResponse added in v0.2.0

type SetDefinitionsClientListByManagementGroupResponse struct {
	// The response of a PolicySetDefinition list operation.
	SetDefinitionListResult
}

SetDefinitionsClientListByManagementGroupResponse contains the response from method SetDefinitionsClient.NewListByManagementGroupPager.

type SetDefinitionsClientListOptions added in v0.2.0

type SetDefinitionsClientListOptions struct {
	// Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion,
	// EffectiveDefinitionVersion'.
	Expand *string

	// The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category
	// eq '{value}”. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned
	// list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided,
	// the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are
	// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes
	// all policy set definitions whose category match the {value}.
	Filter *string

	// Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
	Top *int32
}

SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method.

type SetDefinitionsClientListResponse added in v0.2.0

type SetDefinitionsClientListResponse struct {
	// The response of a PolicySetDefinition list operation.
	SetDefinitionListResult
}

SetDefinitionsClientListResponse contains the response from method SetDefinitionsClient.NewListPager.

type SystemData

type SystemData struct {
	// The timestamp of resource creation (UTC).
	CreatedAt *time.Time

	// The identity that created the resource.
	CreatedBy *string

	// The type of identity that created the resource.
	CreatedByType *CreatedByType

	// The timestamp of resource last modification (UTC)
	LastModifiedAt *time.Time

	// The identity that last modified the resource.
	LastModifiedBy *string

	// The type of identity that last modified the resource.
	LastModifiedByType *CreatedByType
}

SystemData - Metadata pertaining to creation and last modification of the resource.

func (SystemData) MarshalJSON

func (s SystemData) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SystemData.

func (*SystemData) UnmarshalJSON

func (s *SystemData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SystemData.

type TokenOperation added in v1.0.0

type TokenOperation struct {
	// REQUIRED; The http method of the resource operation.
	HTTPMethod *string

	// REQUIRED; The request URI of the resource operation.
	URI *string

	// The payload of the resource operation.
	Content any
}

TokenOperation - The resource operation to acquire a token for.

func (TokenOperation) MarshalJSON added in v1.0.0

func (t TokenOperation) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type TokenOperation.

func (*TokenOperation) UnmarshalJSON added in v1.0.0

func (t *TokenOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TokenOperation.

type TokenRequest added in v1.0.0

type TokenRequest struct {
	// REQUIRED; The resource operation to acquire a token for.
	Operation *TokenOperation

	// The change reference.
	ChangeReference *string
}

TokenRequest - The policy token request properties.

func (TokenRequest) MarshalJSON added in v1.0.0

func (t TokenRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type TokenRequest.

func (*TokenRequest) UnmarshalJSON added in v1.0.0

func (t *TokenRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TokenRequest.

type TokenResponse added in v1.0.0

type TokenResponse struct {
	// The change reference associated with the operation for which the token is acquired.
	ChangeReference *string

	// The expiration of the policy token.
	Expiration *time.Time

	// Status message with additional details about the token acquisition operation result.
	Message *string

	// The result of the completed token acquisition operation. Possible values are Succeeded and Failed.
	Result *PolicyTokenResult

	// An array of external evaluation endpoint invocation results.
	Results []*ExternalEvaluationEndpointInvocationResult

	// The date and time after which the client can try to acquire a token again in the case of retry-able failures.
	RetryAfter *time.Time

	// The issued policy token.
	Token *string

	// The unique Id assigned to the policy token.
	TokenID *string
}

TokenResponse - The policy token response properties.

func (TokenResponse) MarshalJSON added in v1.0.0

func (t TokenResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type TokenResponse.

func (*TokenResponse) UnmarshalJSON added in v1.0.0

func (t *TokenResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TokenResponse.

type TokensClient added in v1.0.0

type TokensClient struct {
	// contains filtered or unexported fields
}

TokensClient contains the methods for the Tokens group. Don't use this type directly, use NewTokensClient() instead.

func NewTokensClient added in v1.0.0

func NewTokensClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TokensClient, error)

NewTokensClient creates a new instance of TokensClient with the specified values.

  • subscriptionID - The ID of the target subscription. The value must be an UUID.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - Contains optional client configuration. Pass nil to accept the default values.

func (*TokensClient) Acquire added in v1.0.0

Acquire - Acquires a policy token.

This operation acquires a policy token in the given subscription for the given request body. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • parameters - The request body
  • options - TokensClientAcquireOptions contains the optional parameters for the TokensClient.Acquire method.
Example

Generated from example definition: 2025-03-01/acquirePolicyToken.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewTokensClient().Acquire(ctx, armpolicy.TokenRequest{
		Operation: &armpolicy.TokenOperation{
			HTTPMethod: to.Ptr("delete"),
			URI:        to.Ptr("https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM?api-version=2024-01-01"),
		},
	}, 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 = armpolicy.TokensClientAcquireResponse{
	// 	TokenResponse: &armpolicy.TokenResponse{
	// 		Expiration: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-01-01T21:30:00.00Z"); return t}()),
	// 		Result: to.Ptr(armpolicy.PolicyTokenResultSucceeded),
	// 		Results: []*armpolicy.ExternalEvaluationEndpointInvocationResult{
	// 			{
	// 				Claims: map[string]any{
	// 					"date": "2025-01-01T19:30:00.00Z",
	// 					"double": 0.99,
	// 					"int": 2,
	// 					"isValid": false,
	// 					"string": "testString",
	// 					"testArray": []any{
	// 						"Apple",
	// 						"Banana",
	// 						"Cherry",
	// 					},
	// 					"testObject": map[string]any{
	// 						"name": "Complex Object",
	// 						"id": 12345,
	// 						"details": map[string]any{
	// 							"createdBy": "John Doe",
	// 							"createdDate": "2024-12-13T12:00:00Z",
	// 							"metadata": map[string]any{
	// 								"isActive": true,
	// 								"tags": []any{
	// 									"example",
	// 									"test",
	// 									"object",
	// 								},
	// 								"version": "1.0.0",
	// 							},
	// 						},
	// 					},
	// 				},
	// 				Expiration: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-01-01T21:30:00.00Z"); return t}()),
	// 				Message: to.Ptr("Coin flip successful (success probability: '1')."),
	// 				PolicyInfo: &armpolicy.LogInfo{
	// 					PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/3f2def86"),
	// 					PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/5ed64d02"),
	// 				},
	// 				Result: to.Ptr(armpolicy.ExternalEndpointResultSucceeded),
	// 			},
	// 		},
	// 		Token: to.Ptr("PoP 7zmVse52pjMKPQd5m2uiNjz5UV2pZ.LPGtRiTeuCDBomEVbzj9kIaL9odEmlNv4D9VzyrQLTAyv4HHnUR7oNytWnL.AQrZ5bSGAQZzr8eySqvugzrD-ceRVL311SL3Nn6f-4c9kgPgU_u1ArXQKW25QCxMlsAuWmaE"),
	// 		TokenID: to.Ptr("0da8a969-c660-4de0-a6a4-b2034d4325e4"),
	// 	},
	// }
}

func (*TokensClient) AcquireAtManagementGroup added in v1.0.0

func (client *TokensClient) AcquireAtManagementGroup(ctx context.Context, managementGroupName string, parameters TokenRequest, options *TokensClientAcquireAtManagementGroupOptions) (TokensClientAcquireAtManagementGroupResponse, error)

AcquireAtManagementGroup - Acquires a policy token at management group level.

This operation acquires a policy token in the given management group for the given request body. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2025-03-01

  • managementGroupName - The name of the management group. The name is case insensitive.
  • parameters - The policy token properties.
  • options - TokensClientAcquireAtManagementGroupOptions contains the optional parameters for the TokensClient.AcquireAtManagementGroup method.
Example

Generated from example definition: 2025-03-01/acquirePolicyTokenAtManagementGroup.json

package main

import (
	"context"
	"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/resources/armpolicy"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpolicy.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewTokensClient().AcquireAtManagementGroup(ctx, "MyManagementGroup", armpolicy.TokenRequest{
		Operation: &armpolicy.TokenOperation{
			HTTPMethod: to.Ptr("delete"),
			URI:        to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000?api-version=2022-04-01"),
		},
	}, 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 = armpolicy.TokensClientAcquireAtManagementGroupResponse{
	// 	TokenResponse: &armpolicy.TokenResponse{
	// 		Expiration: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-01-01T21:30:00.00Z"); return t}()),
	// 		Result: to.Ptr(armpolicy.PolicyTokenResultSucceeded),
	// 		Results: []*armpolicy.ExternalEvaluationEndpointInvocationResult{
	// 			{
	// 				Claims: map[string]any{
	// 					"date": "2025-01-01T19:30:00.00Z",
	// 					"double": 0.99,
	// 					"int": 2,
	// 					"isValid": false,
	// 					"string": "testString",
	// 					"testArray": []any{
	// 						"Apple",
	// 						"Banana",
	// 						"Cherry",
	// 					},
	// 					"testObject": map[string]any{
	// 						"name": "Complex Object",
	// 						"id": 12345,
	// 						"details": map[string]any{
	// 							"createdBy": "John Doe",
	// 							"createdDate": "2024-12-13T12:00:00Z",
	// 							"metadata": map[string]any{
	// 								"isActive": true,
	// 								"tags": []any{
	// 									"example",
	// 									"test",
	// 									"object",
	// 								},
	// 								"version": "1.0.0",
	// 							},
	// 						},
	// 					},
	// 				},
	// 				Expiration: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-01-01T21:30:00.00Z"); return t}()),
	// 				Message: to.Ptr("Coin flip successful (success probability: '1')."),
	// 				PolicyInfo: &armpolicy.LogInfo{
	// 					PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/3f2def86"),
	// 					PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/5ed64d02"),
	// 				},
	// 				Result: to.Ptr(armpolicy.ExternalEndpointResultSucceeded),
	// 			},
	// 		},
	// 		Token: to.Ptr("PoP 7zmVse52pjMKPQd5m2uiNjz5UV2pZ.LPGtRiTeuCDBomEVbzj9kIaL9odEmlNv4D9VzyrQLTAyv4HHnUR7oNytWnL.AQrZ5bSGAQZzr8eySqvugzrD-ceRVL311SL3Nn6f-4c9kgPgU_u1ArXQKW25QCxMlsAuWmaE"),
	// 		TokenID: to.Ptr("0da8a969-c660-4de0-a6a4-b2034d4325e4"),
	// 	},
	// }
}

type TokensClientAcquireAtManagementGroupOptions added in v1.0.0

type TokensClientAcquireAtManagementGroupOptions struct {
}

TokensClientAcquireAtManagementGroupOptions contains the optional parameters for the TokensClient.AcquireAtManagementGroup method.

type TokensClientAcquireAtManagementGroupResponse added in v1.0.0

type TokensClientAcquireAtManagementGroupResponse struct {
	// The policy token response properties.
	TokenResponse
}

TokensClientAcquireAtManagementGroupResponse contains the response from method TokensClient.AcquireAtManagementGroup.

type TokensClientAcquireOptions added in v1.0.0

type TokensClientAcquireOptions struct {
}

TokensClientAcquireOptions contains the optional parameters for the TokensClient.Acquire method.

type TokensClientAcquireResponse added in v1.0.0

type TokensClientAcquireResponse struct {
	// The policy token response properties.
	TokenResponse
}

TokensClientAcquireResponse contains the response from method TokensClient.Acquire.

type UserAssignedIdentitiesValue

type UserAssignedIdentitiesValue struct {
	// READ-ONLY; The client id of user assigned identity.
	ClientID *string

	// READ-ONLY; The principal id of user assigned identity.
	PrincipalID *string
}

func (UserAssignedIdentitiesValue) MarshalJSON added in v0.7.0

func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue.

func (*UserAssignedIdentitiesValue) UnmarshalJSON added in v0.7.0

func (u *UserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL