diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index 668050965304..183fe3c0d7af 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,76 @@ # Release History +## 1.0.0 (2026-02-06) +### Breaking Changes + +- VariableValuesClient and it's operations has been removed +- DataPolicyManifestsClient and it's operations has been removed +- Enum `AliasPathAttributes` has been removed +- Enum `AliasPathTokenType` has been removed +- Enum `AliasPatternType` has been removed +- Enum `AliasType` has been removed +- Enum `AssignmentScopeValidation` has been removed +- Enum `ExemptionCategory` has been removed +- Function `*ClientFactory.NewExemptionsClient` has been removed +- Function `*ClientFactory.NewVariablesClient` has been removed +- Function `NewExemptionsClient` has been removed +- Function `*ExemptionsClient.CreateOrUpdate` has been removed +- Function `*ExemptionsClient.Delete` has been removed +- Function `*ExemptionsClient.Get` has been removed +- Function `*ExemptionsClient.NewListForManagementGroupPager` has been removed +- Function `*ExemptionsClient.NewListForResourceGroupPager` has been removed +- Function `*ExemptionsClient.NewListForResourcePager` has been removed +- Function `*ExemptionsClient.NewListPager` has been removed +- Function `*ExemptionsClient.Update` has been removed +- Function `NewVariablesClient` has been removed +- Function `*VariablesClient.CreateOrUpdate` has been removed +- Function `*VariablesClient.CreateOrUpdateAtManagementGroup` has been removed +- Function `*VariablesClient.Delete` has been removed +- Function `*VariablesClient.DeleteAtManagementGroup` has been removed +- Function `*VariablesClient.Get` has been removed +- Function `*VariablesClient.GetAtManagementGroup` has been removed +- Function `*VariablesClient.NewListForManagementGroupPager` has been removed +- Function `*VariablesClient.NewListPager` has been removed +- Struct `Alias` has been removed +- Struct `AliasPath` has been removed +- Struct `AliasPathMetadata` has been removed +- Struct `AliasPattern` has been removed +- Struct `DataEffect` has been removed +- Struct `Exemption` has been removed +- Struct `ExemptionListResult` has been removed +- Struct `ExemptionProperties` has been removed +- Struct `ExemptionUpdate` has been removed +- Struct `ExemptionUpdateProperties` has been removed +- Struct `ResourceTypeAliases` has been removed +- Struct `Variable` has been removed +- Struct `VariableColumn` has been removed +- Struct `VariableListResult` has been removed +- Struct `VariableProperties` has been removed +- Field `Expand` of struct `AssignmentsClientGetByIDOptions` has been removed + +### Features Added + +- New value `EnforcementModeEnroll` added to enum type `EnforcementMode` +- New value `OverrideKindDefinitionVersion` added to enum type `OverrideKind` +- New enum type `AssignmentType` with values `AssignmentTypeCustom`, `AssignmentTypeNotSpecified`, `AssignmentTypeSystem`, `AssignmentTypeSystemHidden` +- New enum type `ExternalEndpointResult` with values `ExternalEndpointResultFailed`, `ExternalEndpointResultSucceeded` +- New enum type `PolicyTokenResult` with values `PolicyTokenResultFailed`, `PolicyTokenResultSucceeded` +- New function `*ClientFactory.NewTokensClient() *TokensClient` +- New function `NewTokensClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TokensClient, error)` +- New function `*TokensClient.Acquire(ctx context.Context, parameters TokenRequest, options *TokensClientAcquireOptions) (TokensClientAcquireResponse, error)` +- New function `*TokensClient.AcquireAtManagementGroup(ctx context.Context, managementGroupName string, parameters TokenRequest, options *TokensClientAcquireAtManagementGroupOptions) (TokensClientAcquireAtManagementGroupResponse, error)` +- New struct `ExternalEvaluationEndpointInvocationResult` +- New struct `ExternalEvaluationEndpointSettings` +- New struct `ExternalEvaluationEnforcementSettings` +- New struct `LogInfo` +- New struct `TokenOperation` +- New struct `TokenRequest` +- New struct `TokenResponse` +- New field `AssignmentType`, `InstanceID` in struct `AssignmentProperties` +- New field `ExternalEvaluationEnforcementSettings` in struct `DefinitionProperties` +- New field `ExternalEvaluationEnforcementSettings` in struct `DefinitionVersionProperties` + + ## 0.10.0 (2025-03-18) ### Features Added diff --git a/sdk/resourcemanager/resources/armpolicy/assets.json b/sdk/resourcemanager/resources/armpolicy/assets.json index 9f0273551f96..e9c2f7042f4e 100644 --- a/sdk/resourcemanager/resources/armpolicy/assets.json +++ b/sdk/resourcemanager/resources/armpolicy/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/resourcemanager/resources/armpolicy", - "Tag": "go/resourcemanager/resources/armpolicy_22cd1d3678" + "Tag": "go/resourcemanager/resources/armpolicy_ab53483a65" } diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client.go b/sdk/resourcemanager/resources/armpolicy/assignments_client.go index fe18754ab99d..ac451c7487a6 100644 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client.go +++ b/sdk/resourcemanager/resources/armpolicy/assignments_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -18,7 +17,7 @@ import ( "strings" ) -// AssignmentsClient contains the methods for the PolicyAssignments group. +// AssignmentsClient contains the methods for the Assignments group. // Don't use this type directly, use NewAssignmentsClient() instead. type AssignmentsClient struct { internal *arm.Client @@ -28,7 +27,7 @@ type AssignmentsClient struct { // 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 - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,17 +41,13 @@ func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredenti } // 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. +// 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 2023-04-01 -// - scope - The scope of the policy assignment. 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}' -// - policyAssignmentName - The name of the policy assignment. +// 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. func (client *AssignmentsClient) Create(ctx context.Context, scope string, policyAssignmentName string, parameters Assignment, options *AssignmentsClientCreateOptions) (AssignmentsClientCreateResponse, error) { @@ -80,6 +75,9 @@ func (client *AssignmentsClient) Create(ctx context.Context, scope string, polic // createCreateRequest creates the Create request. func (client *AssignmentsClient) createCreateRequest(ctx context.Context, scope string, policyAssignmentName string, parameters Assignment, _ *AssignmentsClientCreateOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if policyAssignmentName == "" { return nil, errors.New("parameter policyAssignmentName cannot be empty") @@ -90,9 +88,10 @@ func (client *AssignmentsClient) createCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -108,18 +107,18 @@ func (client *AssignmentsClient) createHandleResponse(resp *http.Response) (Assi return result, nil } -// CreateByID - 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}'. +// 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 2023-04-01 -// - policyAssignmentID - The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. +// 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 (client *AssignmentsClient) CreateByID(ctx context.Context, policyAssignmentID string, parameters Assignment, options *AssignmentsClientCreateByIDOptions) (AssignmentsClientCreateByIDResponse, error) { @@ -147,15 +146,19 @@ func (client *AssignmentsClient) CreateByID(ctx context.Context, policyAssignmen // createByIDCreateRequest creates the CreateByID request. func (client *AssignmentsClient) createByIDCreateRequest(ctx context.Context, policyAssignmentID string, parameters Assignment, _ *AssignmentsClientCreateByIDOptions) (*policy.Request, error) { urlPath := "/{policyAssignmentId}" + if policyAssignmentID == "" { + return nil, errors.New("parameter policyAssignmentID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentId}", policyAssignmentID) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -172,17 +175,12 @@ func (client *AssignmentsClient) createByIDHandleResponse(resp *http.Response) ( } // 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}'. +// 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 2023-04-01 -// - scope - The scope of the policy assignment. 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}' -// - policyAssignmentName - The name of the policy assignment to delete. +// 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. func (client *AssignmentsClient) Delete(ctx context.Context, scope string, policyAssignmentName string, options *AssignmentsClientDeleteOptions) (AssignmentsClientDeleteResponse, error) { var err error @@ -209,6 +207,9 @@ func (client *AssignmentsClient) Delete(ctx context.Context, scope string, polic // deleteCreateRequest creates the Delete request. func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, scope string, policyAssignmentName string, _ *AssignmentsClientDeleteOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if policyAssignmentName == "" { return nil, errors.New("parameter policyAssignmentName cannot be empty") @@ -219,7 +220,7 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -234,17 +235,17 @@ func (client *AssignmentsClient) deleteHandleResponse(resp *http.Response) (Assi return result, nil } -// DeleteByID - 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}' +// 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 2023-04-01 -// - policyAssignmentID - The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. +// 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 (client *AssignmentsClient) DeleteByID(ctx context.Context, policyAssignmentID string, options *AssignmentsClientDeleteByIDOptions) (AssignmentsClientDeleteByIDResponse, error) { var err error @@ -271,13 +272,16 @@ func (client *AssignmentsClient) DeleteByID(ctx context.Context, policyAssignmen // deleteByIDCreateRequest creates the DeleteByID request. func (client *AssignmentsClient) deleteByIDCreateRequest(ctx context.Context, policyAssignmentID string, _ *AssignmentsClientDeleteByIDOptions) (*policy.Request, error) { urlPath := "/{policyAssignmentId}" + if policyAssignmentID == "" { + return nil, errors.New("parameter policyAssignmentID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentId}", policyAssignmentID) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -295,12 +299,8 @@ func (client *AssignmentsClient) deleteByIDHandleResponse(resp *http.Response) ( // 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 2023-04-01 -// - scope - The scope of the policy assignment. 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}' +// 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. func (client *AssignmentsClient) Get(ctx context.Context, scope string, policyAssignmentName string, options *AssignmentsClientGetOptions) (AssignmentsClientGetResponse, error) { @@ -328,6 +328,9 @@ func (client *AssignmentsClient) Get(ctx context.Context, scope string, policyAs // getCreateRequest creates the Get request. func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope string, policyAssignmentName string, options *AssignmentsClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if policyAssignmentName == "" { return nil, errors.New("parameter policyAssignmentName cannot be empty") @@ -341,7 +344,7 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope str if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -356,15 +359,15 @@ func (client *AssignmentsClient) getHandleResponse(resp *http.Response) (Assignm return result, nil } -// GetByID - 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}'. +// 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 2023-04-01 +// 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 (client *AssignmentsClient) GetByID(ctx context.Context, policyAssignmentID string, options *AssignmentsClientGetByIDOptions) (AssignmentsClientGetByIDResponse, error) { @@ -390,18 +393,18 @@ func (client *AssignmentsClient) GetByID(ctx context.Context, policyAssignmentID } // getByIDCreateRequest creates the GetByID request. -func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, policyAssignmentID string, options *AssignmentsClientGetByIDOptions) (*policy.Request, error) { +func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, policyAssignmentID string, _ *AssignmentsClientGetByIDOptions) (*policy.Request, error) { urlPath := "/{policyAssignmentId}" + if policyAssignmentID == "" { + return nil, errors.New("parameter policyAssignmentID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentId}", policyAssignmentID) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -416,19 +419,19 @@ func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (Ass return result, nil } -// NewListPager - 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 +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. func (client *AssignmentsClient) NewListPager(options *AssignmentsClientListOptions) *runtime.Pager[AssignmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsClientListResponse]{ @@ -468,16 +471,14 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -491,16 +492,17 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign return result, nil } -// NewListForManagementGroupPager - 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. +// NewListForManagementGroupPager - Retrieves all policy assignments that apply to a management group. // -// Generated from API version 2023-04-01 -// - managementGroupID - The ID of the 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. func (client *AssignmentsClient) NewListForManagementGroupPager(managementGroupID string, options *AssignmentsClientListForManagementGroupOptions) *runtime.Pager[AssignmentsClientListForManagementGroupResponse] { @@ -541,16 +543,14 @@ func (client *AssignmentsClient) listForManagementGroupCreateRequest(ctx context if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -564,30 +564,28 @@ func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http return result, nil } -// NewListForResourcePager - 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'). +// 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 2023-04-01 -// - resourceGroupName - The name of the resource group containing the resource. +// 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. @@ -633,7 +631,13 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceProviderNamespace cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceProviderNamespace}", url.PathEscape(resourceProviderNamespace)) + if parentResourcePath == "" { + return nil, errors.New("parameter parentResourcePath cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{parentResourcePath}", parentResourcePath) + if resourceType == "" { + return nil, errors.New("parameter resourceType cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{resourceType}", resourceType) if resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") @@ -647,16 +651,14 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -671,19 +673,17 @@ func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Respon } // 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 +// 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. +// 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 2023-04-01 -// - resourceGroupName - The name of the resource group that contains policy assignments. +// 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. func (client *AssignmentsClient) NewListForResourceGroupPager(resourceGroupName string, options *AssignmentsClientListForResourceGroupOptions) *runtime.Pager[AssignmentsClientListForResourceGroupResponse] { @@ -728,16 +728,14 @@ func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.C if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -752,17 +750,13 @@ func (client *AssignmentsClient) listForResourceGroupHandleResponse(resp *http.R } // 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. +// 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 2023-04-01 -// - scope - The scope of the policy assignment. 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}' -// - policyAssignmentName - The name of the policy assignment. +// 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. func (client *AssignmentsClient) Update(ctx context.Context, scope string, policyAssignmentName string, parameters AssignmentUpdate, options *AssignmentsClientUpdateOptions) (AssignmentsClientUpdateResponse, error) { @@ -790,6 +784,9 @@ func (client *AssignmentsClient) Update(ctx context.Context, scope string, polic // updateCreateRequest creates the Update request. func (client *AssignmentsClient) updateCreateRequest(ctx context.Context, scope string, policyAssignmentName string, parameters AssignmentUpdate, _ *AssignmentsClientUpdateOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if policyAssignmentName == "" { return nil, errors.New("parameter policyAssignmentName cannot be empty") @@ -800,9 +797,10 @@ func (client *AssignmentsClient) updateCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -818,18 +816,18 @@ func (client *AssignmentsClient) updateHandleResponse(resp *http.Response) (Assi return result, nil } -// UpdateByID - 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}'. +// 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 2023-04-01 -// - policyAssignmentID - The ID of the policy assignment to update. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. +// 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. func (client *AssignmentsClient) UpdateByID(ctx context.Context, policyAssignmentID string, parameters AssignmentUpdate, options *AssignmentsClientUpdateByIDOptions) (AssignmentsClientUpdateByIDResponse, error) { @@ -857,15 +855,19 @@ func (client *AssignmentsClient) UpdateByID(ctx context.Context, policyAssignmen // updateByIDCreateRequest creates the UpdateByID request. func (client *AssignmentsClient) updateByIDCreateRequest(ctx context.Context, policyAssignmentID string, parameters AssignmentUpdate, _ *AssignmentsClientUpdateByIDOptions) (*policy.Request, error) { urlPath := "/{policyAssignmentId}" + if policyAssignmentID == "" { + return nil, errors.New("parameter policyAssignmentID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentId}", policyAssignmentID) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go index 69212d32da7e..df4462685b20 100644 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go +++ b/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go @@ -1,73 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyAssignment.json -func ExampleAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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.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"), - // 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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignment.json +// Generated from example definition: 2025-03-01/createPolicyAssignment.json func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -81,7 +33,8 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignment() { NonComplianceMessages: []*armpolicy.NonComplianceMessage{ { Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - }}, + }, + }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "prefix": { Value: "DeptA", @@ -98,38 +51,34 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignment() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { +// Generated from example definition: 2025-03-01/createPolicyAssignmentNonComplianceMessages.json +func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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"), + _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "securityInitAssignment", 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.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", + DisplayName: to.Ptr("Enforce security policies"), + NonComplianceMessages: []*armpolicy.NonComplianceMessage{ + { + Message: to.Ptr("Resources must comply with all internal security policies. See for more info."), }, - "suffix": { - Value: "-LC", + { + 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/policyDefinitions/ResourceNaming"), + PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative"), }, }, nil) if err != nil { @@ -137,31 +86,24 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithASystemA } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { +// Generated from example definition: 2025-03-01/createPolicyAssignmentWithEnrollEnforcement.json +func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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"), + _, 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.EnforcementModeDefault), + EnforcementMode: to.Ptr(armpolicy.EnforcementModeEnroll), Metadata: map[string]any{ - "assignedBy": "Foo Bar", + "assignedBy": "Special Someone", }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "prefix": { @@ -179,33 +121,38 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithAUserAss } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentNonComplianceMessages.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { +// Generated from example definition: 2025-03-01/createPolicyAssignmentWithIdentity.json +func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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{ + _, 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{ - DisplayName: to.Ptr("Enforce security policies"), - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resources must comply with all internal security policies. See for more info."), + 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", }, - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - PolicyDefinitionReferenceID: to.Ptr("10420126870854049575"), + "suffix": { + Value: "-LC", }, - { - 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"), + }, + PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), }, }, nil) if err != nil { @@ -213,21 +160,22 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithMultiple } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithOverrides.json +// Generated from example definition: 2025-03-01/createPolicyAssignmentWithOverrides.json func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithOverrides() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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"), + 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", }, @@ -238,11 +186,27 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithOverride { In: []*string{ to.Ptr("Limit_Skus"), - to.Ptr("Limit_Locations")}, + 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) @@ -251,14 +215,14 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithOverride } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithResourceSelectors.json +// Generated from example definition: 2025-03-01/createPolicyAssignmentWithResourceSelectors.json func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithResourceSelectors() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -277,10 +241,13 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithResource { In: []*string{ to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, + to.Ptr("centraluseuap"), + }, Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, + }, + }, + }, + }, }, }, nil) if err != nil { @@ -288,24 +255,31 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithResource } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithoutEnforcement.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { +// Generated from example definition: 2025-03-01/createPolicyAssignmentWithUserAssignedIdentity.json +func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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.EnforcementModeDoNotEnforce), + EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), Metadata: map[string]any{ - "assignedBy": "Special Someone", + "assignedBy": "Foo Bar", }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "prefix": { @@ -323,523 +297,377 @@ func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithoutEnfor } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignment.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignment() { +// Generated from example definition: 2025-03-01/createPolicyAssignmentWithoutEnforcement.json +func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.AssignmentsClientGetOptions{Expand: nil}) + _, 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) } - // 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.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), - // 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"), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithASystemAssignedIdentity() { +// Generated from example definition: 2025-03-01/deletePolicyAssignment.json +func ExampleAssignmentsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.AssignmentsClientGetOptions{Expand: nil}) + 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.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), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", + // 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", // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithAUserAssignedIdentity() { +// Generated from example definition: 2025-03-01/getPolicyAssignment.json +func ExampleAssignmentsClient_Get_retrieveAPolicyAssignment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.AssignmentsClientGetOptions{Expand: nil}) + 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.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"), + // 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", // }, - // }, - // }, - // 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), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", + // NotScopes: []*string{ // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.AssignmentsClientGetOptions{Expand: 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.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), - // 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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.AssignmentsClientGetOptions{Expand: 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.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), - // 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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithASystemAssignedIdentity() { +// Generated from example definition: 2025-03-01/getPolicyAssignmentWithIdentity.json +func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithASystemAssignedIdentity() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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) + 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.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), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ + // 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"), // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", + // 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", // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithAUserAssignedIdentity() { +// Generated from example definition: 2025-03-01/getPolicyAssignmentWithOverrides.json +func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithOverrides() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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) + 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.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"), + // 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", // }, - // }, - // }, - // 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), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", + // NotScopes: []*string{ // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithOverrides() { +// Generated from example definition: 2025-03-01/getPolicyAssignmentWithResourceSelectors.json +func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithResourceSelectors() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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) + 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.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), - // 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"), - // }}, + // 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"), // }, - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithResourceSelectors() { +// Generated from example definition: 2025-03-01/getPolicyAssignmentWithUserAssignedIdentity.json +func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithAUserAssignedIdentity() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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) + 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.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), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ + // 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"), + // }, + // }, // }, - // 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), - // }}, - // }}, + // 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"), // }, - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignmentsForResourceGroup.json -func ExampleAssignmentsClient_NewListForResourceGroupPager() { +// Generated from example definition: 2025-03-01/listPolicyAssignments.json +func ExampleAssignmentsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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{Filter: to.Ptr("atScope()"), - Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"), - Top: nil, - }) + 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 { @@ -850,73 +678,77 @@ func ExampleAssignmentsClient_NewListForResourceGroupPager() { _ = 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.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"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ + // 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"), // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", + // 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"), // }, - // 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"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // NotScopes: []*string{ + // { + // 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"), // }, - // 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"), // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignmentsForResource.json -func ExampleAssignmentsClient_NewListForResourcePager() { +// Generated from example definition: 2025-03-01/listPolicyAssignmentsForManagementGroup.json +func ExampleAssignmentsClient_NewListForManagementGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.AssignmentsClientListForResourceOptions{Filter: nil, - Expand: nil, - Top: nil, - }) + 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 { @@ -927,69 +759,75 @@ func ExampleAssignmentsClient_NewListForResourcePager() { _ = 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.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("VM Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ + // 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"), // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/vmSkus"), - // 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"), - // NotScopes: []*string{ + // { + // 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"), // }, - // 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"), // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignmentsForManagementGroup.json -func ExampleAssignmentsClient_NewListForManagementGroupPager() { +// Generated from example definition: 2025-03-01/listPolicyAssignmentsForResource.json +func ExampleAssignmentsClient_NewListForResourcePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().NewListForManagementGroupPager("TestManagementGroup", &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()"), - Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"), - Top: nil, - }) + 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 { @@ -1000,73 +838,73 @@ func ExampleAssignmentsClient_NewListForManagementGroupPager() { _ = 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/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"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // Metadata: map[string]any{ - // "category": "Cost Management", + // 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"), // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"), // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/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"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // NotScopes: []*string{ + // { + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"), // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignments.json -func ExampleAssignmentsClient_NewListPager() { +// Generated from example definition: 2025-03-01/listPolicyAssignmentsForResourceGroup.json +func ExampleAssignmentsClient_NewListForResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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()"), + pager := clientFactory.NewAssignmentsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.AssignmentsClientListForResourceGroupOptions{ Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"), - Top: nil, - }) + Filter: to.Ptr("atScope()")}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1077,288 +915,286 @@ func ExampleAssignmentsClient_NewListPager() { _ = 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*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"), - // 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"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // Metadata: map[string]any{ - // "category": "Cost Management", + // 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"), // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), // }, - // }, - // { - // Name: to.Ptr("TagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/TagEnforcement"), - // 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"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // NotScopes: []*string{ + // { + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyAssignmentById.json -func ExampleAssignmentsClient_DeleteByID() { +// Generated from example definition: 2025-03-01/updatePolicyAssignmentWithIdentity.json +func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithASystemAssignedIdentity() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAssignmentsClient().DeleteByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", nil) + 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", + // 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"), // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().CreateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - DefinitionVersion: to.Ptr("1.*.*"), - DisplayName: to.Ptr("Enforce storage account SKU"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Cheapskate Boss", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentWithAManagedIdentityById() { +// Generated from example definition: 2025-03-01/updatePolicyAssignmentWithOverrides.json +func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithOverrides() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewAssignmentsClient().CreateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - DefinitionVersion: to.Ptr("1.*.*"), - DisplayName: to.Ptr("Enforce storage account SKU"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Cheapskate Boss", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", + 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"), }, }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().GetByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", &armpolicy.AssignmentsClientGetByIDOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentWithAManagedIdentityById() { +// Generated from example definition: 2025-03-01/updatePolicyAssignmentWithResourceSelectors.json +func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithResourceSelectors() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAssignmentsClient().GetByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", &armpolicy.AssignmentsClientGetByIDOptions{Expand: nil}) + 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // 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("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_UpdateByID() { +// Generated from example definition: 2025-03-01/updatePolicyAssignmentWithUserAssignedIdentity.json +func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithAUserAssignedIdentity() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAssignmentsClient().UpdateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.AssignmentUpdate{ + res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), + 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) @@ -1368,35 +1204,43 @@ func ExampleAssignmentsClient_UpdateByID() { // 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // 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("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ + // 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"), + // }, + // }, // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), // }, // } } diff --git a/sdk/resourcemanager/resources/armpolicy/autorest.md b/sdk/resourcemanager/resources/armpolicy/autorest.md deleted file mode 100644 index c39acb0a4cd8..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/autorest.md +++ /dev/null @@ -1,14 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.10.0 -package-policy: true -tag: package-policy-2023-04 -``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/build.go b/sdk/resourcemanager/resources/armpolicy/build.go deleted file mode 100644 index de9f18c95391..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -removeUnreferencedTypes resourcemanager/resources/armpolicy - -package armpolicy diff --git a/sdk/resourcemanager/resources/armpolicy/client_factory.go b/sdk/resourcemanager/resources/armpolicy/client_factory.go index 0f7b551eb66a..14bb7b2238f9 100644 --- a/sdk/resourcemanager/resources/armpolicy/client_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/client_factory.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -41,13 +40,6 @@ func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { } } -// NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient. -func (c *ClientFactory) NewDataPolicyManifestsClient() *DataPolicyManifestsClient { - return &DataPolicyManifestsClient{ - internal: c.internal, - } -} - // NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient. func (c *ClientFactory) NewDefinitionVersionsClient() *DefinitionVersionsClient { return &DefinitionVersionsClient{ @@ -64,14 +56,6 @@ func (c *ClientFactory) NewDefinitionsClient() *DefinitionsClient { } } -// NewExemptionsClient creates a new instance of ExemptionsClient. -func (c *ClientFactory) NewExemptionsClient() *ExemptionsClient { - return &ExemptionsClient{ - subscriptionID: c.subscriptionID, - internal: c.internal, - } -} - // NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient. func (c *ClientFactory) NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient { return &SetDefinitionVersionsClient{ @@ -88,17 +72,9 @@ func (c *ClientFactory) NewSetDefinitionsClient() *SetDefinitionsClient { } } -// NewVariableValuesClient creates a new instance of VariableValuesClient. -func (c *ClientFactory) NewVariableValuesClient() *VariableValuesClient { - return &VariableValuesClient{ - subscriptionID: c.subscriptionID, - internal: c.internal, - } -} - -// NewVariablesClient creates a new instance of VariablesClient. -func (c *ClientFactory) NewVariablesClient() *VariablesClient { - return &VariablesClient{ +// NewTokensClient creates a new instance of TokensClient. +func (c *ClientFactory) NewTokensClient() *TokensClient { + return &TokensClient{ subscriptionID: c.subscriptionID, internal: c.internal, } diff --git a/sdk/resourcemanager/resources/armpolicy/constants.go b/sdk/resourcemanager/resources/armpolicy/constants.go index fdb2d10201a5..21eaa7067d30 100644 --- a/sdk/resourcemanager/resources/armpolicy/constants.go +++ b/sdk/resourcemanager/resources/armpolicy/constants.go @@ -1,135 +1,45 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy -const ( - moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - moduleVersion = "v0.10.0" -) - -// AliasPathAttributes - The attributes of the token that the alias path is referring to. -type AliasPathAttributes string - -const ( - // AliasPathAttributesModifiable - The token that the alias path is referring to is modifiable by policies with 'modify' effect. - AliasPathAttributesModifiable AliasPathAttributes = "Modifiable" - // AliasPathAttributesNone - The token that the alias path is referring to has no attributes. - AliasPathAttributesNone AliasPathAttributes = "None" -) - -// PossibleAliasPathAttributesValues returns the possible values for the AliasPathAttributes const type. -func PossibleAliasPathAttributesValues() []AliasPathAttributes { - return []AliasPathAttributes{ - AliasPathAttributesModifiable, - AliasPathAttributesNone, - } -} - -// AliasPathTokenType - The type of the token that the alias path is referring to. -type AliasPathTokenType string - -const ( - // AliasPathTokenTypeAny - The token type can be anything. - AliasPathTokenTypeAny AliasPathTokenType = "Any" - // AliasPathTokenTypeArray - The token type is array. - AliasPathTokenTypeArray AliasPathTokenType = "Array" - // AliasPathTokenTypeBoolean - The token type is boolean. - AliasPathTokenTypeBoolean AliasPathTokenType = "Boolean" - // AliasPathTokenTypeInteger - The token type is integer. - AliasPathTokenTypeInteger AliasPathTokenType = "Integer" - // AliasPathTokenTypeNotSpecified - The token type is not specified. - AliasPathTokenTypeNotSpecified AliasPathTokenType = "NotSpecified" - // AliasPathTokenTypeNumber - The token type is number. - AliasPathTokenTypeNumber AliasPathTokenType = "Number" - // AliasPathTokenTypeObject - The token type is object. - AliasPathTokenTypeObject AliasPathTokenType = "Object" - // AliasPathTokenTypeString - The token type is string. - AliasPathTokenTypeString AliasPathTokenType = "String" -) - -// PossibleAliasPathTokenTypeValues returns the possible values for the AliasPathTokenType const type. -func PossibleAliasPathTokenTypeValues() []AliasPathTokenType { - return []AliasPathTokenType{ - AliasPathTokenTypeAny, - AliasPathTokenTypeArray, - AliasPathTokenTypeBoolean, - AliasPathTokenTypeInteger, - AliasPathTokenTypeNotSpecified, - AliasPathTokenTypeNumber, - AliasPathTokenTypeObject, - AliasPathTokenTypeString, - } -} - -// AliasPatternType - The type of alias pattern -type AliasPatternType string - -const ( - // AliasPatternTypeExtract - Extract is the only allowed value. - AliasPatternTypeExtract AliasPatternType = "Extract" - // AliasPatternTypeNotSpecified - NotSpecified is not allowed. - AliasPatternTypeNotSpecified AliasPatternType = "NotSpecified" -) - -// PossibleAliasPatternTypeValues returns the possible values for the AliasPatternType const type. -func PossibleAliasPatternTypeValues() []AliasPatternType { - return []AliasPatternType{ - AliasPatternTypeExtract, - AliasPatternTypeNotSpecified, - } -} - -// AliasType - The type of the alias. -type AliasType string +// AssignmentType - The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. +type AssignmentType string const ( - // AliasTypeMask - Alias value is secret. - AliasTypeMask AliasType = "Mask" - // AliasTypeNotSpecified - Alias type is unknown (same as not providing alias type). - AliasTypeNotSpecified AliasType = "NotSpecified" - // AliasTypePlainText - Alias value is not secret. - AliasTypePlainText AliasType = "PlainText" + // 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" ) -// PossibleAliasTypeValues returns the possible values for the AliasType const type. -func PossibleAliasTypeValues() []AliasType { - return []AliasType{ - AliasTypeMask, - AliasTypeNotSpecified, - AliasTypePlainText, +// PossibleAssignmentTypeValues returns the possible values for the AssignmentType const type. +func PossibleAssignmentTypeValues() []AssignmentType { + return []AssignmentType{ + AssignmentTypeCustom, + AssignmentTypeNotSpecified, + AssignmentTypeSystem, + AssignmentTypeSystemHidden, } } -// AssignmentScopeValidation - The option whether validate the exemption is at or under the assignment scope. -type AssignmentScopeValidation string - -const ( - // AssignmentScopeValidationDefault - This option will validate the exemption is at or under the assignment scope. - AssignmentScopeValidationDefault AssignmentScopeValidation = "Default" - // AssignmentScopeValidationDoNotValidate - This option will bypass the validation the exemption scope is at or under the - // policy assignment scope. - AssignmentScopeValidationDoNotValidate AssignmentScopeValidation = "DoNotValidate" -) - -// PossibleAssignmentScopeValidationValues returns the possible values for the AssignmentScopeValidation const type. -func PossibleAssignmentScopeValidationValues() []AssignmentScopeValidation { - return []AssignmentScopeValidation{ - AssignmentScopeValidationDefault, - AssignmentScopeValidationDoNotValidate, - } -} - -// CreatedByType - The type of identity that created the resource. +// CreatedByType - The kind of entity that created the resource. type CreatedByType string const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" + // 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 CreatedByType = "User" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) // PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. @@ -142,7 +52,7 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// EnforcementMode - The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. +// EnforcementMode - The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll type EnforcementMode string const ( @@ -150,6 +60,9 @@ const ( 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" ) // PossibleEnforcementModeValues returns the possible values for the EnforcementMode const type. @@ -157,25 +70,25 @@ func PossibleEnforcementModeValues() []EnforcementMode { return []EnforcementMode{ EnforcementModeDefault, EnforcementModeDoNotEnforce, + EnforcementModeEnroll, } } -// ExemptionCategory - The policy exemption category. Possible values are Waiver and Mitigated. -type ExemptionCategory string +// ExternalEndpointResult - The result of the external endpoint. Possible values are Succeeded and Failed. +type ExternalEndpointResult string const ( - // ExemptionCategoryMitigated - This category of exemptions usually means the mitigation actions have been applied to the - // scope. - ExemptionCategoryMitigated ExemptionCategory = "Mitigated" - // ExemptionCategoryWaiver - This category of exemptions usually means the scope is not applicable for the policy. - ExemptionCategoryWaiver ExemptionCategory = "Waiver" + // ExternalEndpointResultFailed - The external endpoint failed. + ExternalEndpointResultFailed ExternalEndpointResult = "Failed" + // ExternalEndpointResultSucceeded - The external endpoint succeeded. + ExternalEndpointResultSucceeded ExternalEndpointResult = "Succeeded" ) -// PossibleExemptionCategoryValues returns the possible values for the ExemptionCategory const type. -func PossibleExemptionCategoryValues() []ExemptionCategory { - return []ExemptionCategory{ - ExemptionCategoryMitigated, - ExemptionCategoryWaiver, +// PossibleExternalEndpointResultValues returns the possible values for the ExternalEndpointResult const type. +func PossibleExternalEndpointResultValues() []ExternalEndpointResult { + return []ExternalEndpointResult{ + ExternalEndpointResultFailed, + ExternalEndpointResultSucceeded, } } @@ -183,6 +96,8 @@ func PossibleExemptionCategoryValues() []ExemptionCategory { type OverrideKind string 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" ) @@ -190,6 +105,7 @@ const ( // PossibleOverrideKindValues returns the possible values for the OverrideKind const type. func PossibleOverrideKindValues() []OverrideKind { return []OverrideKind{ + OverrideKindDefinitionVersion, OverrideKindPolicyEffect, } } @@ -198,13 +114,20 @@ func PossibleOverrideKindValues() []OverrideKind { type ParameterType string const ( - ParameterTypeArray ParameterType = "Array" - ParameterTypeBoolean ParameterType = "Boolean" + // 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 ParameterType = "Float" - ParameterTypeInteger ParameterType = "Integer" - ParameterTypeObject ParameterType = "Object" - ParameterTypeString ParameterType = "String" + // 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" ) // PossibleParameterTypeValues returns the possible values for the ParameterType const type. @@ -220,14 +143,36 @@ func PossibleParameterTypeValues() []ParameterType { } } +// PolicyTokenResult - The result of the completed token acquisition operation. Possible values are Succeeded and Failed. +type PolicyTokenResult string + +const ( + // PolicyTokenResultFailed - The token acquisition failed. + PolicyTokenResultFailed PolicyTokenResult = "Failed" + // PolicyTokenResultSucceeded - The token acquisition succeeded. + PolicyTokenResultSucceeded PolicyTokenResult = "Succeeded" +) + +// PossiblePolicyTokenResultValues returns the possible values for the PolicyTokenResult const type. +func PossiblePolicyTokenResultValues() []PolicyTokenResult { + return []PolicyTokenResult{ + PolicyTokenResultFailed, + PolicyTokenResultSucceeded, + } +} + // PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. type PolicyType string const ( - PolicyTypeBuiltIn PolicyType = "BuiltIn" - PolicyTypeCustom PolicyType = "Custom" + // 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 PolicyType = "Static" + // PolicyTypeStatic - The static policy definition type. + PolicyTypeStatic PolicyType = "Static" ) // PossiblePolicyTypeValues returns the possible values for the PolicyType const type. diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go deleted file mode 100644 index 33e794033acd..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// DataPolicyManifestsClient contains the methods for the DataPolicyManifests group. -// Don't use this type directly, use NewDataPolicyManifestsClient() instead. -type DataPolicyManifestsClient struct { - internal *arm.Client -} - -// NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewDataPolicyManifestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DataPolicyManifestsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &DataPolicyManifestsClient{ - internal: cl, - } - return client, nil -} - -// GetByPolicyMode - This operation retrieves the data policy manifest with the given policy mode. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-09-01 -// - policyMode - The policy mode of the data policy manifest to get. -// - options - DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode -// method. -func (client *DataPolicyManifestsClient) GetByPolicyMode(ctx context.Context, policyMode string, options *DataPolicyManifestsClientGetByPolicyModeOptions) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - var err error - const operationName = "DataPolicyManifestsClient.GetByPolicyMode" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getByPolicyModeCreateRequest(ctx, policyMode, options) - if err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - resp, err := client.getByPolicyModeHandleResponse(httpResp) - return resp, err -} - -// getByPolicyModeCreateRequest creates the GetByPolicyMode request. -func (client *DataPolicyManifestsClient) getByPolicyModeCreateRequest(ctx context.Context, policyMode string, _ *DataPolicyManifestsClientGetByPolicyModeOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}" - if policyMode == "" { - return nil, errors.New("parameter policyMode cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyMode}", url.PathEscape(policyMode)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-09-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByPolicyModeHandleResponse handles the GetByPolicyMode response. -func (client *DataPolicyManifestsClient) getByPolicyModeHandleResponse(resp *http.Response) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - result := DataPolicyManifestsClientGetByPolicyModeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifest); err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves a list of all the data policy manifests that match the optional given $filter. -// Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the -// unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned -// list only includes all data policy manifests that have a namespace matching -// the provided value. -// -// Generated from API version 2020-09-01 -// - options - DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.NewListPager -// method. -func (client *DataPolicyManifestsClient) NewListPager(options *DataPolicyManifestsClientListOptions) *runtime.Pager[DataPolicyManifestsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[DataPolicyManifestsClientListResponse]{ - More: func(page DataPolicyManifestsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DataPolicyManifestsClientListResponse) (DataPolicyManifestsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataPolicyManifestsClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return DataPolicyManifestsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *DataPolicyManifestsClient) listCreateRequest(ctx context.Context, options *DataPolicyManifestsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Authorization/dataPolicyManifests" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-09-01") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *DataPolicyManifestsClient) listHandleResponse(resp *http.Response) (DataPolicyManifestsClientListResponse, error) { - result := DataPolicyManifestsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifestListResult); err != nil { - return DataPolicyManifestsClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go deleted file mode 100644 index 4d96d58808a5..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json -func ExampleDataPolicyManifestsClient_GetByPolicyMode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDataPolicyManifestsClient().GetByPolicyMode(ctx, "Microsoft.KeyVault.Data", 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.DataPolicyManifest = armpolicy.DataPolicyManifest{ - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("Audit"), - // }, - // { - // Name: to.Ptr("Deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json -func ExampleDataPolicyManifestsClient_NewListPager_listDataPolicyManifests() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDataPolicyManifestsClient().NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: 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.DataPolicyManifestListResult = armpolicy.DataPolicyManifestListResult{ - // Value: []*armpolicy.DataPolicyManifest{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // }, - // { - // Name: to.Ptr("deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Kubernetes.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.Kubernetes.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // DetailsSchema: map[string]any{ - // "type": "object", - // "additionalProperties": false, - // "properties":map[string]any{ - // "constraint":map[string]any{ - // "type": "string", - // "pattern": "^(?i)(https:\\/\\/raw\\.githubusercontent\\.com\\/){1}(.+)(\\.){1}(yaml|yml){1}$", - // }, - // "constraintTemplate":map[string]any{ - // "type": "string", - // "pattern": "^(?i)(https:\\/\\/raw\\.githubusercontent\\.com\\/){1}(.+)(\\.){1}(yaml|yml){1}$", - // }, - // "values":map[string]any{ - // "type": "object", - // "additionalProperties":map[string]any{ - // }, - // "maxProperties": float64(10), - // }, - // }, - // "required":[]any{ - // "constraintTemplate", - // }, - // }, - // }}, - // IsBuiltInOnly: to.Ptr(false), - // Namespaces: []*string{ - // to.Ptr("Microsoft.Kubernetes"), - // to.Ptr("Microsoft.ContainerService")}, - // PolicyMode: to.Ptr("Microsoft.Kubernetes.Data"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json -func ExampleDataPolicyManifestsClient_NewListPager_listDataPolicyManifestsWithNamespaceFilter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDataPolicyManifestsClient().NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: to.Ptr("namespace eq 'Microsoft.KeyVault'")}) - 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.DataPolicyManifestListResult = armpolicy.DataPolicyManifestListResult{ - // Value: []*armpolicy.DataPolicyManifest{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // }, - // { - // Name: to.Ptr("deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client.go b/sdk/resourcemanager/resources/armpolicy/definitions_client.go index b681240c5742..9532665e6a36 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitions_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -18,7 +17,7 @@ import ( "strings" ) -// DefinitionsClient contains the methods for the PolicyDefinitions group. +// DefinitionsClient contains the methods for the Definitions group. // Don't use this type directly, use NewDefinitionsClient() instead. type DefinitionsClient struct { internal *arm.Client @@ -28,7 +27,7 @@ type DefinitionsClient struct { // 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 - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -44,8 +43,8 @@ func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredenti // 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 2023-04-01 -// - policyDefinitionName - The name of the policy definition to create. +// 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. @@ -87,9 +86,10 @@ func (client *DefinitionsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -109,9 +109,9 @@ func (client *DefinitionsClient) createOrUpdateHandleResponse(resp *http.Respons // the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. -// - policyDefinitionName - The name of the policy definition to create. +// - 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. @@ -153,9 +153,10 @@ func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -174,8 +175,8 @@ func (client *DefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(r // 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 2023-04-01 -// - policyDefinitionName - The name of the policy definition to delete. +// 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. func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionName string, options *DefinitionsClientDeleteOptions) (DefinitionsClientDeleteResponse, error) { var err error @@ -214,18 +215,17 @@ func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policy return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. -// - policyDefinitionName - The name of the policy definition to delete. +// - policyDefinitionName - The name of the policy definition to get. // - options - DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup // method. func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientDeleteAtManagementGroupOptions) (DefinitionsClientDeleteAtManagementGroupResponse, error) { @@ -265,16 +265,15 @@ func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2023-04-01 +// 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. func (client *DefinitionsClient) Get(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetOptions) (DefinitionsClientGetResponse, error) { @@ -315,7 +314,7 @@ func (client *DefinitionsClient) getCreateRequest(ctx context.Context, policyDef return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -333,7 +332,7 @@ func (client *DefinitionsClient) getHandleResponse(resp *http.Response) (Definit // 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 2023-04-01 +// 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 @@ -376,7 +375,7 @@ func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -394,7 +393,7 @@ func (client *DefinitionsClient) getAtManagementGroupHandleResponse(resp *http.R // 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 2023-04-01 +// 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. func (client *DefinitionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetBuiltInOptions) (DefinitionsClientGetBuiltInResponse, error) { @@ -431,7 +430,7 @@ func (client *DefinitionsClient) getBuiltInCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -447,16 +446,15 @@ func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) ( } // 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}' +// 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}. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.NewListPager method. func (client *DefinitionsClient) NewListPager(options *DefinitionsClientListOptions) *runtime.Pager[DefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DefinitionsClientListResponse]{ @@ -493,16 +491,14 @@ func (client *DefinitionsClient) listCreateRequest(ctx context.Context, options return nil, err } reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -517,12 +513,11 @@ func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (Defini } // 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}. +// $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 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager // method. func (client *DefinitionsClient) NewListBuiltInPager(options *DefinitionsClientListBuiltInOptions) *runtime.Pager[DefinitionsClientListBuiltInResponse] { @@ -556,16 +551,14 @@ func (client *DefinitionsClient) listBuiltInCreateRequest(ctx context.Context, o return nil, err } reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -580,17 +573,15 @@ func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) } // 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}. +// 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 2023-04-01 +// 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. @@ -629,16 +620,14 @@ func (client *DefinitionsClient) listByManagementGroupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go index a54d0750545d..6f4859cb4bec 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go +++ b/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinition.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinition.json func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinition() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -68,14 +65,14 @@ func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinition() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionAdvancedParams.json func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinitionWithAdvancedParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -91,12 +88,13 @@ func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinitionWith "requiredRetentionDays": { Type: to.Ptr(armpolicy.ParameterTypeInteger), AllowedValues: []any{ - float64(0), - float64(30), - float64(90), - float64(180), - float64(365)}, - DefaultValue: float64(365), + 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)"), @@ -134,160 +132,73 @@ func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinitionWith } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinition.json -func ExampleDefinitionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().Delete(ctx, "ResourceNaming", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinition.json -func ExampleDefinitionsClient_Get() { +// Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json +func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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) + _, 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) } - // 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.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")}, - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltinPolicyDefinition.json -func ExampleDefinitionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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.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")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json func ExampleDefinitionsClient_CreateOrUpdateAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -333,31 +244,126 @@ func ExampleDefinitionsClient_CreateOrUpdateAtManagementGroup() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinitionAtManagementGroup.json +// Generated from example definition: 2025-03-01/deletePolicyDefinition.json +func ExampleDefinitionsClient_Delete() { + 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{ + // } +} + +// Generated from example definition: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json func ExampleDefinitionsClient_DeleteAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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{ + // } +} + +// Generated from example definition: 2025-03-01/getPolicyDefinition.json +func ExampleDefinitionsClient_Get() { + 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().DeleteAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", nil) + 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"), + // }, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinitionAtManagementGroup.json +// Generated from example definition: 2025-03-01/getPolicyDefinitionAtManagementGroup.json func ExampleDefinitionsClient_GetAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -368,67 +374,135 @@ func ExampleDefinitionsClient_GetAtManagementGroup() { // 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.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"), + // 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"), + // }, // }, // }, - // "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"), + // }, // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", + // }, + // } +} + +// Generated from example definition: 2025-03-01/getBuiltinPolicyDefinition.json +func ExampleDefinitionsClient_GetBuiltIn() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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"), + // }, // }, // }, - // "then":map[string]any{ - // "effect": "deny", + // 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"), // }, // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitions.json +// Generated from example definition: 2025-03-01/listPolicyDefinitions.json func ExampleDefinitionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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(&armpolicy.DefinitionsClientListOptions{Filter: nil, - Top: nil, - }) + pager := clientFactory.NewDefinitionsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -439,51 +513,53 @@ func ExampleDefinitionsClient_NewListPager() { _ = 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.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"), + // 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')]", + // 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", + // }, // }, - // "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"), // }, // }, - // 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"), @@ -513,13 +589,13 @@ func ExampleDefinitionsClient_NewListPager() { // }, // }, // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ + // "if": map[string]any{ + // "not": map[string]any{ // "field": "name", // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", // }, // }, - // "then":map[string]any{ + // "then": map[string]any{ // "effect": "deny", // }, // }, @@ -527,63 +603,65 @@ func ExampleDefinitionsClient_NewListPager() { // Version: to.Ptr("1.2.1"), // Versions: []*string{ // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, + // 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"), - // }, + // }, + // { + // 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", - // }, + // }, + // PolicyRule: map[string]any{ + // "if": map[string]any{ + // "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn", + // "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]", // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, + // "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"), + // }, + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicyDefinitions.json +// Generated from example definition: 2025-03-01/listBuiltInPolicyDefinitions.json func ExampleDefinitionsClient_NewListBuiltInPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewDefinitionsClient().NewListBuiltInPager(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) + pager := clientFactory.NewDefinitionsClient().NewListBuiltInPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -594,39 +672,41 @@ func ExampleDefinitionsClient_NewListBuiltInPager() { _ = 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.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"}, + // 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{ + // "if": map[string]any{ // "equals": "Microsoft.Sql/servers/databases", // "field": "type", // }, - // "then":map[string]any{ + // "then": map[string]any{ // "effect": "AuditIfNotExists", - // "details":map[string]any{ + // "details": map[string]any{ // "name": "default", // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ + // "existenceCondition": map[string]any{ + // "allOf": []any{ // map[string]any{ // "equals": "[parameters('setting')]", // "field": "Microsoft.Sql/auditingSettings.state", @@ -640,107 +720,110 @@ func ExampleDefinitionsClient_NewListBuiltInPager() { // Version: to.Ptr("1.2.1"), // Versions: []*string{ // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, + // 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"), - // }, + // }, + // { + // 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')]", - // }, + // }, + // 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")}, + // "then": map[string]any{ + // "effect": "Deny", // }, // }, - // { - // 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")}, + // 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"), + // }, + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitionsByManagementGroup.json +// Generated from example definition: 2025-03-01/listPolicyDefinitionsByManagementGroup.json func ExampleDefinitionsClient_NewListByManagementGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) + pager := clientFactory.NewDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -751,51 +834,53 @@ func ExampleDefinitionsClient_NewListByManagementGroupPager() { _ = 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.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"), + // 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')]", + // 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", + // }, // }, - // "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"), // }, // }, - // 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"), @@ -825,13 +910,13 @@ func ExampleDefinitionsClient_NewListByManagementGroupPager() { // }, // }, // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ + // "if": map[string]any{ + // "not": map[string]any{ // "field": "name", // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", // }, // }, - // "then":map[string]any{ + // "then": map[string]any{ // "effect": "deny", // }, // }, @@ -839,9 +924,12 @@ func ExampleDefinitionsClient_NewListByManagementGroupPager() { // Version: to.Ptr("1.2.1"), // Versions: []*string{ // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, + // to.Ptr("1.0.0"), // }, - // }}, - // } + // }, + // }, + // }, + // }, + // } } } diff --git a/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go index c77086c9fb53..ccaaf37c6855 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -18,7 +17,7 @@ import ( "strings" ) -// DefinitionVersionsClient contains the methods for the PolicyDefinitionVersions group. +// DefinitionVersionsClient contains the methods for the DefinitionVersions group. // Don't use this type directly, use NewDefinitionVersionsClient() instead. type DefinitionVersionsClient struct { internal *arm.Client @@ -28,7 +27,7 @@ type DefinitionVersionsClient struct { // 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 - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewDefinitionVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionVersionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -44,7 +43,7 @@ func NewDefinitionVersionsClient(subscriptionID string, credential azcore.TokenC // 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 2023-04-01 +// 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 @@ -93,9 +92,10 @@ func (client *DefinitionVersionsClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -115,7 +115,7 @@ func (client *DefinitionVersionsClient) createOrUpdateHandleResponse(resp *http. // group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -165,9 +165,10 @@ func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -186,7 +187,7 @@ func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupHandleRes // 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 2023-04-01 +// 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 @@ -233,16 +234,15 @@ func (client *DefinitionVersionsClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2023-04-01 +// 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 @@ -290,16 +290,15 @@ func (client *DefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2023-04-01 +// 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 @@ -346,7 +345,7 @@ func (client *DefinitionVersionsClient) getCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -365,7 +364,7 @@ func (client *DefinitionVersionsClient) getHandleResponse(resp *http.Response) ( // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -414,7 +413,7 @@ func (client *DefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -432,7 +431,7 @@ func (client *DefinitionVersionsClient) getAtManagementGroupHandleResponse(resp // 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 2023-04-01 +// 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 @@ -476,7 +475,7 @@ func (client *DefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -493,7 +492,7 @@ func (client *DefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Resp // NewListPager - This operation retrieves a list of all the policy definition versions for the given policy definition. // -// Generated from API version 2023-04-01 +// 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. @@ -539,7 +538,7 @@ func (client *DefinitionVersionsClient) listCreateRequest(ctx context.Context, p if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -554,10 +553,12 @@ func (client *DefinitionVersionsClient) listHandleResponse(resp *http.Response) return result, nil } -// ListAll - This operation lists all the policy definition versions for all policy definitions within a subscription. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll // method. func (client *DefinitionVersionsClient) ListAll(ctx context.Context, options *DefinitionVersionsClientListAllOptions) (DefinitionVersionsClientListAllResponse, error) { @@ -594,7 +595,7 @@ func (client *DefinitionVersionsClient) listAllCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -609,11 +610,12 @@ func (client *DefinitionVersionsClient) listAllHandleResponse(resp *http.Respons return result, nil } -// ListAllAtManagementGroup - This operation lists all the policy definition versions for all policy definitions at the management -// group scope. +// 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 2023-04-01 +// 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. @@ -651,7 +653,7 @@ func (client *DefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -666,10 +668,12 @@ func (client *DefinitionVersionsClient) listAllAtManagementGroupHandleResponse(r return result, nil } -// ListAllBuiltins - This operation lists all the built-in policy definition versions for all built-in policy definitions. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins // method. func (client *DefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *DefinitionVersionsClientListAllBuiltinsOptions) (DefinitionVersionsClientListAllBuiltinsResponse, error) { @@ -702,7 +706,7 @@ func (client *DefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -720,7 +724,7 @@ func (client *DefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http // NewListBuiltInPager - This operation retrieves a list of all the built-in policy definition versions for the given policy // definition. // -// Generated from API version 2023-04-01 +// 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. @@ -762,7 +766,7 @@ func (client *DefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Con if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -780,7 +784,7 @@ func (client *DefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Res // 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 2023-04-01 +// 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 @@ -827,7 +831,7 @@ func (client *DefinitionVersionsClient) listByManagementGroupCreateRequest(ctx c if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go index d64753ca5470..feb71f44d2cd 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go +++ b/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go @@ -1,358 +1,130 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllBuiltInPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_ListAllBuiltins() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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.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"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json -func ExampleDefinitionVersionsClient_ListAllAtManagementGroup() { +// Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json +func ExampleDefinitionVersionsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().ListAllAtManagementGroup(ctx, "MyManagementGroup", nil) + 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.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"), + // 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", // }, - // }, - // { - // 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"), - // }, + // 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"), // }, // }, - // 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", + // "suffix": &armpolicy.ParameterDefinitionsValue{ + // Type: to.Ptr(armpolicy.ParameterTypeString), + // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ + // Description: to.Ptr("Resource name suffix"), + // DisplayName: to.Ptr("Suffix"), // }, // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_ListAll() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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.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'))]", // }, // }, - // 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", - // }, + // "then": map[string]any{ + // "effect": "deny", // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, + // 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/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"), - // }, - // }}, + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionVersion.json -func ExampleDefinitionVersionsClient_CreateOrUpdate() { +// Generated from example definition: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json +func ExampleDefinitionVersionsClient_CreateOrUpdateAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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{ + 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"), @@ -396,75 +168,104 @@ func ExampleDefinitionVersionsClient_CreateOrUpdate() { // 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.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"), - // }, + // 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", // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), + // 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"), + // }, // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", + // "suffix": &armpolicy.ParameterDefinitionsValue{ + // Type: to.Ptr(armpolicy.ParameterTypeString), + // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ + // Description: to.Ptr("Resource name suffix"), + // DisplayName: to.Ptr("Suffix"), + // }, // }, // }, - // "then":map[string]any{ - // "effect": "deny", + // 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"), // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinitionVersion.json +// Generated from example definition: 2025-03-01/deletePolicyDefinitionVersion.json func ExampleDefinitionVersionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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{ + // } +} + +// Generated from example definition: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json +func ExampleDefinitionVersionsClient_DeleteAtManagementGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewDefinitionVersionsClient().Delete(ctx, "ResourceNaming", "1.2.1", nil) + 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{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinitionVersion.json +// Generated from example definition: 2025-03-01/getPolicyDefinitionVersion.json func ExampleDefinitionVersionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -475,58 +276,124 @@ func ExampleDefinitionVersionsClient_Get() { // 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.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"), + // 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"), + // }, // }, // }, - // "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"), // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", + // }, + // } +} + +// Generated from example definition: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json +func ExampleDefinitionVersionsClient_GetAtManagementGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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"), + // }, // }, // }, - // "then":map[string]any{ - // "effect": "deny", + // 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"), // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltinPolicyDefinitionVersion.json +// Generated from example definition: 2025-03-01/getBuiltinPolicyDefinitionVersion.json func ExampleDefinitionVersionsClient_GetBuiltIn() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -537,351 +404,515 @@ func ExampleDefinitionVersionsClient_GetBuiltIn() { // 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.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"), + // 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')]", + // 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", + // }, // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, + // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), + // Version: to.Ptr("1.2.1"), // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json -func ExampleDefinitionVersionsClient_CreateOrUpdateAtManagementGroup() { +// Generated from example definition: 2025-03-01/listPolicyDefinitionVersions.json +func ExampleDefinitionVersionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().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) + 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"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/listAllPolicyDefinitionVersions.json +func ExampleDefinitionVersionsClient_ListAll() { + 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.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"), + // 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"), // }, // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", + // { + // 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"), // }, // }, - // "then":map[string]any{ - // "effect": "deny", - // }, // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json -func ExampleDefinitionVersionsClient_DeleteAtManagementGroup() { +// Generated from example definition: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json +func ExampleDefinitionVersionsClient_ListAllAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewDefinitionVersionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", nil) + 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"), + // }, + // }, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinitionVersionAtManagementGroup.json -func ExampleDefinitionVersionsClient_GetAtManagementGroup() { +// Generated from example definition: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json +func ExampleDefinitionVersionsClient_ListAllBuiltins() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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) + 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.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"), + // 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"), // }, // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", + // { + // 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"), // }, // }, - // "then":map[string]any{ - // "effect": "deny", - // }, // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionVersionsClient().NewListPager("ResourceNaming", &armpolicy.DefinitionVersionsClientListOptions{Top: 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.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/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"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicyDefinitionVersions.json +// Generated from example definition: 2025-03-01/listBuiltInPolicyDefinitionVersions.json func ExampleDefinitionVersionsClient_NewListBuiltInPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewDefinitionVersionsClient().NewListBuiltInPager("06a78e20-9358-41c9-923c-fb736d382a12", &armpolicy.DefinitionVersionsClientListBuiltInOptions{Top: nil}) + pager := clientFactory.NewDefinitionVersionsClient().NewListBuiltInPager("06a78e20-9358-41c9-923c-fb736d382a12", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -892,39 +923,41 @@ func ExampleDefinitionVersionsClient_NewListBuiltInPager() { _ = 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.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"}, + // 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{ + // "if": map[string]any{ // "equals": "Microsoft.Sql/servers/databases", // "field": "type", // }, - // "then":map[string]any{ + // "then": map[string]any{ // "effect": "AuditIfNotExists", - // "details":map[string]any{ + // "details": map[string]any{ // "name": "default", // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ + // "existenceCondition": map[string]any{ + // "allOf": []any{ // map[string]any{ // "equals": "[parameters('setting')]", // "field": "Microsoft.Sql/auditingSettings.state", @@ -952,53 +985,56 @@ func ExampleDefinitionVersionsClient_NewListBuiltInPager() { // AllowedValues: []any{ // "enabled", // "disabled", - // "default"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, + // "default", // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", + // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ + // DisplayName: to.Ptr("Audit Setting"), // }, - // "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", - // }, + // }, + // }, + // 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"), // }, - // }}, - // } + // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), + // Version: to.Ptr("1.0.0"), + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitionVersionsByManagementGroup.json +// Generated from example definition: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json func ExampleDefinitionVersionsClient_NewListByManagementGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "ResourceNaming", &armpolicy.DefinitionVersionsClientListByManagementGroupOptions{Top: nil}) + pager := clientFactory.NewDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "ResourceNaming", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1009,92 +1045,95 @@ func ExampleDefinitionVersionsClient_NewListByManagementGroupPager() { _ = 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.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"), - // }, + // 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", // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), + // 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"), + // }, // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", + // "suffix": &armpolicy.ParameterDefinitionsValue{ + // Type: to.Ptr(armpolicy.ParameterTypeString), + // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ + // Description: to.Ptr("Resource name suffix"), + // DisplayName: to.Ptr("Suffix"), + // }, // }, // }, - // "then":map[string]any{ - // "effect": "deny", + // 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"), // }, - // 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"), - // }, + // { + // 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", // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), + // 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"), + // }, // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]", + // "suffix": &armpolicy.ParameterDefinitionsValue{ + // Type: to.Ptr(armpolicy.ParameterTypeString), + // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ + // Description: to.Ptr("Resource name suffix"), + // DisplayName: to.Ptr("Suffix"), + // }, // }, // }, - // "then":map[string]any{ - // "effect": "deny", + // 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"), // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go deleted file mode 100644 index f22fdbbf2149..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go +++ /dev/null @@ -1,583 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ExemptionsClient contains the methods for the PolicyExemptions group. -// Don't use this type directly, use NewExemptionsClient() instead. -type ExemptionsClient struct { - internal *arm.Client - subscriptionID string -} - -// NewExemptionsClient creates a new instance of ExemptionsClient 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 - pass nil to accept the default values. -func NewExemptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExemptionsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &ExemptionsClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a policy exemption with the given scope and name. Policy exemptions -// apply to all resources contained within their scope. For example, when you create a policy -// exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable -// resources in the resource group. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. 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}' -// - policyExemptionName - The name of the policy exemption to delete. -// - parameters - Parameters for the policy exemption. -// - options - ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate -// method. -func (client *ExemptionsClient) CreateOrUpdate(ctx context.Context, scope string, policyExemptionName string, parameters Exemption, options *ExemptionsClientCreateOrUpdateOptions) (ExemptionsClientCreateOrUpdateResponse, error) { - var err error - const operationName = "ExemptionsClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, scope, policyExemptionName, parameters, options) - if err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExemptionsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, policyExemptionName string, parameters Exemption, _ *ExemptionsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ExemptionsClient) createOrUpdateHandleResponse(resp *http.Response) (ExemptionsClientCreateOrUpdateResponse, error) { - result := ExemptionsClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy -// exemption is the part of its ID preceding -// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. 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}' -// - policyExemptionName - The name of the policy exemption to delete. -// - options - ExemptionsClientDeleteOptions contains the optional parameters for the ExemptionsClient.Delete method. -func (client *ExemptionsClient) Delete(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientDeleteOptions) (ExemptionsClientDeleteResponse, error) { - var err error - const operationName = "ExemptionsClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, scope, policyExemptionName, options) - if err != nil { - return ExemptionsClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientDeleteResponse{}, err - } - return ExemptionsClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ExemptionsClient) deleteCreateRequest(ctx context.Context, scope string, policyExemptionName string, _ *ExemptionsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single policy exemption, given its name and the scope it was created at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. 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}' -// - policyExemptionName - The name of the policy exemption to delete. -// - options - ExemptionsClientGetOptions contains the optional parameters for the ExemptionsClient.Get method. -func (client *ExemptionsClient) Get(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientGetOptions) (ExemptionsClientGetResponse, error) { - var err error - const operationName = "ExemptionsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, scope, policyExemptionName, options) - if err != nil { - return ExemptionsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *ExemptionsClient) getCreateRequest(ctx context.Context, scope string, policyExemptionName string, _ *ExemptionsClientGetOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (ExemptionsClientGetResponse, error) { - result := ExemptionsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all policy exemptions associated with the given subscription that match -// the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', -// 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not provided, the unfiltered list includes all policy -// exemptions 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. -// -// Generated from API version 2022-07-01-preview -// - options - ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.NewListPager method. -func (client *ExemptionsClient) NewListPager(options *ExemptionsClientListOptions) *runtime.Pager[ExemptionsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListResponse]{ - More: func(page ExemptionsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListResponse) (ExemptionsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return ExemptionsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *ExemptionsClient) listCreateRequest(ctx context.Context, options *ExemptionsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (ExemptionsClientListResponse, error) { - result := ExemptionsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all policy exemptions applicable to the management -// group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', -// 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter=atScope() is provided, the returned list includes all -// policy exemptions that are assigned to the management group or the management -// group's ancestors. -// -// Generated from API version 2022-07-01-preview -// - managementGroupID - The ID of the management group. -// - options - ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.NewListForManagementGroupPager -// method. -func (client *ExemptionsClient) NewListForManagementGroupPager(managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) *runtime.Pager[ExemptionsClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForManagementGroupResponse]{ - More: func(page ExemptionsClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForManagementGroupResponse) (ExemptionsClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForManagementGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) - }, nil) - if err != nil { - return ExemptionsClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *ExemptionsClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http.Response) (ExemptionsClientListForManagementGroupResponse, error) { - result := ExemptionsClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForManagementGroupResponse{}, err - } - return result, nil -} - -// NewListForResourcePager - This operation retrieves the list of all policy exemptions 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()', 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not -// provided, the unfiltered list includes all policy exemptions 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. 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 2022-07-01-preview -// - resourceGroupName - The name of the resource group containing the resource. -// - 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 - ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.NewListForResourcePager -// method. -func (client *ExemptionsClient) NewListForResourcePager(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) *runtime.Pager[ExemptionsClientListForResourceResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForResourceResponse]{ - More: func(page ExemptionsClientListForResourceResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceResponse) (ExemptionsClientListForResourceResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForResourcePager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) - }, nil) - if err != nil { - return ExemptionsClientListForResourceResponse{}, err - } - return client.listForResourceHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForResourceCreateRequest creates the ListForResource request. -func (client *ExemptionsClient) listForResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if resourceProviderNamespace == "" { - return nil, errors.New("parameter resourceProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceProviderNamespace}", url.PathEscape(resourceProviderNamespace)) - urlPath = strings.ReplaceAll(urlPath, "{parentResourcePath}", parentResourcePath) - urlPath = strings.ReplaceAll(urlPath, "{resourceType}", resourceType) - if resourceName == "" { - return nil, errors.New("parameter resourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForResourceHandleResponse handles the ListForResource response. -func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Response) (ExemptionsClientListForResourceResponse, error) { - result := ExemptionsClientListForResourceResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForResourceResponse{}, err - } - return result, nil -} - -// NewListForResourceGroupPager - This operation retrieves the list of all policy exemptions associated with the given resource -// group in the given subscription that match the optional given $filter. Valid values for $filter are: -// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not provided, the -// unfiltered list includes all policy exemptions 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. -// -// Generated from API version 2022-07-01-preview -// - resourceGroupName - The name of the resource group containing the resource. -// - options - ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.NewListForResourceGroupPager -// method. -func (client *ExemptionsClient) NewListForResourceGroupPager(resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) *runtime.Pager[ExemptionsClientListForResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForResourceGroupResponse]{ - More: func(page ExemptionsClientListForResourceGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceGroupResponse) (ExemptionsClientListForResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForResourceGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) - }, nil) - if err != nil { - return ExemptionsClientListForResourceGroupResponse{}, err - } - return client.listForResourceGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForResourceGroupCreateRequest creates the ListForResourceGroup request. -func (client *ExemptionsClient) listForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForResourceGroupHandleResponse handles the ListForResourceGroup response. -func (client *ExemptionsClient) listForResourceGroupHandleResponse(resp *http.Response) (ExemptionsClientListForResourceGroupResponse, error) { - result := ExemptionsClientListForResourceGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForResourceGroupResponse{}, err - } - return result, nil -} - -// Update - This operation updates a policy exemption with the given scope and name. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. 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}' -// - policyExemptionName - The name of the policy exemption to delete. -// - parameters - Parameters for policy exemption patch request. -// - options - ExemptionsClientUpdateOptions contains the optional parameters for the ExemptionsClient.Update method. -func (client *ExemptionsClient) Update(ctx context.Context, scope string, policyExemptionName string, parameters ExemptionUpdate, options *ExemptionsClientUpdateOptions) (ExemptionsClientUpdateResponse, error) { - var err error - const operationName = "ExemptionsClient.Update" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, scope, policyExemptionName, parameters, options) - if err != nil { - return ExemptionsClientUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientUpdateResponse{}, err - } - resp, err := client.updateHandleResponse(httpResp) - return resp, err -} - -// updateCreateRequest creates the Update request. -func (client *ExemptionsClient) updateCreateRequest(ctx context.Context, scope string, policyExemptionName string, parameters ExemptionUpdate, _ *ExemptionsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// updateHandleResponse handles the Update response. -func (client *ExemptionsClient) updateHandleResponse(resp *http.Response) (ExemptionsClientUpdateResponse, error) { - result := ExemptionsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientUpdateResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go deleted file mode 100644 index ff6ca02e393e..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go +++ /dev/null @@ -1,636 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/deletePolicyExemption.json -func ExampleExemptionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExemptionsClient().Delete(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemption.json -func ExampleExemptionsClient_CreateOrUpdate_createOrUpdateAPolicyExemption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().CreateOrUpdate(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr("Exempt demo cluster from limit sku"), - DisplayName: to.Ptr("Exempt demo cluster"), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]any{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_CreateOrUpdate_createOrUpdateAPolicyExemptionWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().CreateOrUpdate(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr("Exempt demo cluster from limit sku"), - AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - DisplayName: to.Ptr("Exempt demo cluster"), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]any{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/getPolicyExemption.json -func ExampleExemptionsClient_Get_retrieveAPolicyExemption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/getPolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_Get_retrieveAPolicyExemptionWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/updatePolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.ExemptionUpdate{ - Properties: &armpolicy.ExemptionUpdateProperties{ - AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForSubscription.json -func ExampleExemptionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListPager(&armpolicy.ExemptionsClientListOptions{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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("TestVMSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVMSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("TestVNetSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVNetSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json -func ExampleExemptionsClient_NewListForResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.ExemptionsClientListForResourceGroupOptions{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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("TestVMSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVMSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("TestVNetRG"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyExemptions/TestVNetRG"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForResource.json -func ExampleExemptionsClient_NewListForResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForResourcePager("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", "MyTestComputer.cloudapp.net", &armpolicy.ExemptionsClientListForResourceOptions{Filter: 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("DemoExpensiveVMGroup"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVMGroup"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("jumpBoxExemption"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Compute/virtualMachines/MyTestVm/providers/Microsoft.Authorization/policyExemptions/jumpBoxExemption"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json -func ExampleExemptionsClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForManagementGroupPager("DevOrg", &armpolicy.ExemptionsClientListForManagementGroupOptions{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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("ResearchBudgetExemption"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyExemptions/ResearchBudgetExemption"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/HardwareDivision/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("VNetIsMonitored"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyExemptions/VNetIsMonitored"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/HardwareDivision/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go b/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go index fc3c46250297..c11d554f6f25 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -167,7 +166,7 @@ func (a *AssignmentsServerTransport) dispatchCreate(req *http.Request) (*http.Re const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.Assignment](req) @@ -204,7 +203,7 @@ func (a *AssignmentsServerTransport) dispatchCreateByID(req *http.Request) (*htt const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.Assignment](req) @@ -237,7 +236,7 @@ func (a *AssignmentsServerTransport) dispatchDelete(req *http.Request) (*http.Re const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -270,7 +269,7 @@ func (a *AssignmentsServerTransport) dispatchDeleteByID(req *http.Request) (*htt const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyAssignmentIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyAssignmentId")]) @@ -299,7 +298,7 @@ func (a *AssignmentsServerTransport) dispatchGet(req *http.Request) (*http.Respo const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -344,26 +343,14 @@ func (a *AssignmentsServerTransport) dispatchGetByID(req *http.Request) (*http.R const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() policyAssignmentIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyAssignmentId")]) if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) - if err != nil { - return nil, err - } - expandParam := getOptional(expandUnescaped) - var options *armpolicy.AssignmentsClientGetByIDOptions - if expandParam != nil { - options = &armpolicy.AssignmentsClientGetByIDOptions{ - Expand: expandParam, - } - } - respr, errRespr := a.srv.GetByID(req.Context(), policyAssignmentIDParam, options) + respr, errRespr := a.srv.GetByID(req.Context(), policyAssignmentIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -387,7 +374,7 @@ func (a *AssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -453,7 +440,7 @@ func (a *AssignmentsServerTransport) dispatchNewListForManagementGroupPager(req const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -523,7 +510,7 @@ func (a *AssignmentsServerTransport) dispatchNewListForResourcePager(req *http.R const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { + if len(matches) < 7 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -609,7 +596,7 @@ func (a *AssignmentsServerTransport) dispatchNewListForResourceGroupPager(req *h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -677,7 +664,7 @@ func (a *AssignmentsServerTransport) dispatchUpdate(req *http.Request) (*http.Re const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.AssignmentUpdate](req) @@ -714,7 +701,7 @@ func (a *AssignmentsServerTransport) dispatchUpdateByID(req *http.Request) (*htt const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.AssignmentUpdate](req) diff --git a/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go b/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go deleted file mode 100644 index 358e7be95812..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// DataPolicyManifestsServer is a fake server for instances of the armpolicy.DataPolicyManifestsClient type. -type DataPolicyManifestsServer struct { - // GetByPolicyMode is the fake for method DataPolicyManifestsClient.GetByPolicyMode - // HTTP status codes to indicate success: http.StatusOK - GetByPolicyMode func(ctx context.Context, policyMode string, options *armpolicy.DataPolicyManifestsClientGetByPolicyModeOptions) (resp azfake.Responder[armpolicy.DataPolicyManifestsClientGetByPolicyModeResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method DataPolicyManifestsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.DataPolicyManifestsClientListOptions) (resp azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]) -} - -// NewDataPolicyManifestsServerTransport creates a new instance of DataPolicyManifestsServerTransport with the provided implementation. -// The returned DataPolicyManifestsServerTransport instance is connected to an instance of armpolicy.DataPolicyManifestsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewDataPolicyManifestsServerTransport(srv *DataPolicyManifestsServer) *DataPolicyManifestsServerTransport { - return &DataPolicyManifestsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]](), - } -} - -// DataPolicyManifestsServerTransport connects instances of armpolicy.DataPolicyManifestsClient to instances of DataPolicyManifestsServer. -// Don't use this type directly, use NewDataPolicyManifestsServerTransport instead. -type DataPolicyManifestsServerTransport struct { - srv *DataPolicyManifestsServer - newListPager *tracker[azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]] -} - -// Do implements the policy.Transporter interface for DataPolicyManifestsServerTransport. -func (d *DataPolicyManifestsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return d.dispatchToMethodFake(req, method) -} - -func (d *DataPolicyManifestsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if dataPolicyManifestsServerTransportInterceptor != nil { - res.resp, res.err, intercepted = dataPolicyManifestsServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "DataPolicyManifestsClient.GetByPolicyMode": - res.resp, res.err = d.dispatchGetByPolicyMode(req) - case "DataPolicyManifestsClient.NewListPager": - res.resp, res.err = d.dispatchNewListPager(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (d *DataPolicyManifestsServerTransport) dispatchGetByPolicyMode(req *http.Request) (*http.Response, error) { - if d.srv.GetByPolicyMode == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByPolicyMode not implemented")} - } - const regexStr = `/providers/Microsoft\.Authorization/dataPolicyManifests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - policyModeParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyMode")]) - if err != nil { - return nil, err - } - respr, errRespr := d.srv.GetByPolicyMode(req.Context(), policyModeParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataPolicyManifest, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (d *DataPolicyManifestsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if d.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := d.newListPager.get(req) - if newListPager == nil { - qp := req.URL.Query() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.DataPolicyManifestsClientListOptions - if filterParam != nil { - options = &armpolicy.DataPolicyManifestsClientListOptions{ - Filter: filterParam, - } - } - resp := d.srv.NewListPager(options) - newListPager = &resp - d.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.DataPolicyManifestsClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - d.newListPager.remove(req) - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to DataPolicyManifestsServerTransport -var dataPolicyManifestsServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go index 3717b38d0b59..828f2ac17998 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -153,7 +152,7 @@ func (d *DefinitionsServerTransport) dispatchCreateOrUpdate(req *http.Request) ( const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.Definition](req) @@ -186,7 +185,7 @@ func (d *DefinitionsServerTransport) dispatchCreateOrUpdateAtManagementGroup(req const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.Definition](req) @@ -223,7 +222,7 @@ func (d *DefinitionsServerTransport) dispatchDelete(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) @@ -252,7 +251,7 @@ func (d *DefinitionsServerTransport) dispatchDeleteAtManagementGroup(req *http.R const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) @@ -285,7 +284,7 @@ func (d *DefinitionsServerTransport) dispatchGet(req *http.Request) (*http.Respo const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) @@ -314,7 +313,7 @@ func (d *DefinitionsServerTransport) dispatchGetAtManagementGroup(req *http.Requ const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) @@ -347,7 +346,7 @@ func (d *DefinitionsServerTransport) dispatchGetBuiltIn(req *http.Request) (*htt const regexStr = `/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) @@ -378,7 +377,7 @@ func (d *DefinitionsServerTransport) dispatchNewListPager(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -492,7 +491,7 @@ func (d *DefinitionsServerTransport) dispatchNewListByManagementGroupPager(req * const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() diff --git a/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go index da1930251b30..8cd0dc941a4c 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -171,7 +170,7 @@ func (d *DefinitionVersionsServerTransport) dispatchCreateOrUpdate(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.DefinitionVersion](req) @@ -208,7 +207,7 @@ func (d *DefinitionVersionsServerTransport) dispatchCreateOrUpdateAtManagementGr const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.DefinitionVersion](req) @@ -249,7 +248,7 @@ func (d *DefinitionVersionsServerTransport) dispatchDelete(req *http.Request) (* const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) @@ -282,7 +281,7 @@ func (d *DefinitionVersionsServerTransport) dispatchDeleteAtManagementGroup(req const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) @@ -319,7 +318,7 @@ func (d *DefinitionVersionsServerTransport) dispatchGet(req *http.Request) (*htt const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) @@ -352,7 +351,7 @@ func (d *DefinitionVersionsServerTransport) dispatchGetAtManagementGroup(req *ht const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) @@ -389,7 +388,7 @@ func (d *DefinitionVersionsServerTransport) dispatchGetBuiltIn(req *http.Request const regexStr = `/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) @@ -424,7 +423,7 @@ func (d *DefinitionVersionsServerTransport) dispatchNewListPager(req *http.Reque const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -480,7 +479,7 @@ func (d *DefinitionVersionsServerTransport) dispatchListAll(req *http.Request) ( const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicyDefinitionVersions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } respr, errRespr := d.srv.ListAll(req.Context(), nil) @@ -505,7 +504,7 @@ func (d *DefinitionVersionsServerTransport) dispatchListAllAtManagementGroup(req const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicyDefinitionVersions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) @@ -555,7 +554,7 @@ func (d *DefinitionVersionsServerTransport) dispatchNewListBuiltInPager(req *htt const regexStr = `/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -613,7 +612,7 @@ func (d *DefinitionVersionsServerTransport) dispatchNewListByManagementGroupPage const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() diff --git a/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go deleted file mode 100644 index c42f814585e9..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go +++ /dev/null @@ -1,490 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// ExemptionsServer is a fake server for instances of the armpolicy.ExemptionsClient type. -type ExemptionsServer struct { - // CreateOrUpdate is the fake for method ExemptionsClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, scope string, policyExemptionName string, parameters armpolicy.Exemption, options *armpolicy.ExemptionsClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.ExemptionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method ExemptionsClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, scope string, policyExemptionName string, options *armpolicy.ExemptionsClientDeleteOptions) (resp azfake.Responder[armpolicy.ExemptionsClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method ExemptionsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, scope string, policyExemptionName string, options *armpolicy.ExemptionsClientGetOptions) (resp azfake.Responder[armpolicy.ExemptionsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method ExemptionsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.ExemptionsClientListOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]) - - // NewListForManagementGroupPager is the fake for method ExemptionsClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, options *armpolicy.ExemptionsClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]) - - // NewListForResourcePager is the fake for method ExemptionsClient.NewListForResourcePager - // HTTP status codes to indicate success: http.StatusOK - NewListForResourcePager func(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *armpolicy.ExemptionsClientListForResourceOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]) - - // NewListForResourceGroupPager is the fake for method ExemptionsClient.NewListForResourceGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForResourceGroupPager func(resourceGroupName string, options *armpolicy.ExemptionsClientListForResourceGroupOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]) - - // Update is the fake for method ExemptionsClient.Update - // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, scope string, policyExemptionName string, parameters armpolicy.ExemptionUpdate, options *armpolicy.ExemptionsClientUpdateOptions) (resp azfake.Responder[armpolicy.ExemptionsClientUpdateResponse], errResp azfake.ErrorResponder) -} - -// NewExemptionsServerTransport creates a new instance of ExemptionsServerTransport with the provided implementation. -// The returned ExemptionsServerTransport instance is connected to an instance of armpolicy.ExemptionsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewExemptionsServerTransport(srv *ExemptionsServer) *ExemptionsServerTransport { - return &ExemptionsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]](), - newListForResourcePager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]](), - newListForResourceGroupPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]](), - } -} - -// ExemptionsServerTransport connects instances of armpolicy.ExemptionsClient to instances of ExemptionsServer. -// Don't use this type directly, use NewExemptionsServerTransport instead. -type ExemptionsServerTransport struct { - srv *ExemptionsServer - newListPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]] - newListForResourcePager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]] - newListForResourceGroupPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]] -} - -// Do implements the policy.Transporter interface for ExemptionsServerTransport. -func (e *ExemptionsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return e.dispatchToMethodFake(req, method) -} - -func (e *ExemptionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if exemptionsServerTransportInterceptor != nil { - res.resp, res.err, intercepted = exemptionsServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "ExemptionsClient.CreateOrUpdate": - res.resp, res.err = e.dispatchCreateOrUpdate(req) - case "ExemptionsClient.Delete": - res.resp, res.err = e.dispatchDelete(req) - case "ExemptionsClient.Get": - res.resp, res.err = e.dispatchGet(req) - case "ExemptionsClient.NewListPager": - res.resp, res.err = e.dispatchNewListPager(req) - case "ExemptionsClient.NewListForManagementGroupPager": - res.resp, res.err = e.dispatchNewListForManagementGroupPager(req) - case "ExemptionsClient.NewListForResourcePager": - res.resp, res.err = e.dispatchNewListForResourcePager(req) - case "ExemptionsClient.NewListForResourceGroupPager": - res.resp, res.err = e.dispatchNewListForResourceGroupPager(req) - case "ExemptionsClient.Update": - res.resp, res.err = e.dispatchUpdate(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (e *ExemptionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if e.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Exemption](req) - if err != nil { - return nil, err - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.CreateOrUpdate(req.Context(), scopeParam, policyExemptionNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if e.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Delete(req.Context(), scopeParam, policyExemptionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if e.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Get(req.Context(), scopeParam, policyExemptionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := e.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListPager(options) - newListPager = &resp - e.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.ExemptionsClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - e.newListPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := e.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForManagementGroupOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForManagementGroupOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForManagementGroupPager(managementGroupIDParam, options) - newListForManagementGroupPager = &resp - e.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.ExemptionsClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - e.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForResourcePager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForResourcePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForResourcePager not implemented")} - } - newListForResourcePager := e.newListForResourcePager.get(req) - if newListForResourcePager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourcePathParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourcePath")]) - if err != nil { - return nil, err - } - resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForResourceOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForResourceOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForResourcePager(resourceGroupNameParam, resourceProviderNamespaceParam, parentResourcePathParam, resourceTypeParam, resourceNameParam, options) - newListForResourcePager = &resp - e.newListForResourcePager.add(req, newListForResourcePager) - server.PagerResponderInjectNextLinks(newListForResourcePager, req, func(page *armpolicy.ExemptionsClientListForResourceResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForResourcePager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForResourcePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForResourcePager) { - e.newListForResourcePager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForResourceGroupPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForResourceGroupPager not implemented")} - } - newListForResourceGroupPager := e.newListForResourceGroupPager.get(req) - if newListForResourceGroupPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForResourceGroupOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForResourceGroupOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForResourceGroupPager(resourceGroupNameParam, options) - newListForResourceGroupPager = &resp - e.newListForResourceGroupPager.add(req, newListForResourceGroupPager) - server.PagerResponderInjectNextLinks(newListForResourceGroupPager, req, func(page *armpolicy.ExemptionsClientListForResourceGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForResourceGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForResourceGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForResourceGroupPager) { - e.newListForResourceGroupPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if e.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.ExemptionUpdate](req) - if err != nil { - return nil, err - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Update(req.Context(), scopeParam, policyExemptionNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to ExemptionsServerTransport -var exemptionsServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/internal.go b/sdk/resourcemanager/resources/armpolicy/fake/internal.go index c614f8d5643a..41e62ec29233 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/internal.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/internal.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake diff --git a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go index 7d16b3ac430a..0744929a6b75 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,29 +18,20 @@ type ServerFactory struct { // AssignmentsServer contains the fakes for client AssignmentsClient AssignmentsServer AssignmentsServer - // DataPolicyManifestsServer contains the fakes for client DataPolicyManifestsClient - DataPolicyManifestsServer DataPolicyManifestsServer - // DefinitionVersionsServer contains the fakes for client DefinitionVersionsClient DefinitionVersionsServer DefinitionVersionsServer // DefinitionsServer contains the fakes for client DefinitionsClient DefinitionsServer DefinitionsServer - // ExemptionsServer contains the fakes for client ExemptionsClient - ExemptionsServer ExemptionsServer - // SetDefinitionVersionsServer contains the fakes for client SetDefinitionVersionsClient SetDefinitionVersionsServer SetDefinitionVersionsServer // SetDefinitionsServer contains the fakes for client SetDefinitionsClient SetDefinitionsServer SetDefinitionsServer - // VariableValuesServer contains the fakes for client VariableValuesClient - VariableValuesServer VariableValuesServer - - // VariablesServer contains the fakes for client VariablesClient - VariablesServer VariablesServer + // TokensServer contains the fakes for client TokensClient + TokensServer TokensServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -59,14 +49,11 @@ type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex trAssignmentsServer *AssignmentsServerTransport - trDataPolicyManifestsServer *DataPolicyManifestsServerTransport trDefinitionVersionsServer *DefinitionVersionsServerTransport trDefinitionsServer *DefinitionsServerTransport - trExemptionsServer *ExemptionsServerTransport trSetDefinitionVersionsServer *SetDefinitionVersionsServerTransport trSetDefinitionsServer *SetDefinitionsServerTransport - trVariableValuesServer *VariableValuesServerTransport - trVariablesServer *VariablesServerTransport + trTokensServer *TokensServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -85,11 +72,6 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "AssignmentsClient": initServer(s, &s.trAssignmentsServer, func() *AssignmentsServerTransport { return NewAssignmentsServerTransport(&s.srv.AssignmentsServer) }) resp, err = s.trAssignmentsServer.Do(req) - case "DataPolicyManifestsClient": - initServer(s, &s.trDataPolicyManifestsServer, func() *DataPolicyManifestsServerTransport { - return NewDataPolicyManifestsServerTransport(&s.srv.DataPolicyManifestsServer) - }) - resp, err = s.trDataPolicyManifestsServer.Do(req) case "DefinitionVersionsClient": initServer(s, &s.trDefinitionVersionsServer, func() *DefinitionVersionsServerTransport { return NewDefinitionVersionsServerTransport(&s.srv.DefinitionVersionsServer) @@ -98,9 +80,6 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "DefinitionsClient": initServer(s, &s.trDefinitionsServer, func() *DefinitionsServerTransport { return NewDefinitionsServerTransport(&s.srv.DefinitionsServer) }) resp, err = s.trDefinitionsServer.Do(req) - case "ExemptionsClient": - initServer(s, &s.trExemptionsServer, func() *ExemptionsServerTransport { return NewExemptionsServerTransport(&s.srv.ExemptionsServer) }) - resp, err = s.trExemptionsServer.Do(req) case "SetDefinitionVersionsClient": initServer(s, &s.trSetDefinitionVersionsServer, func() *SetDefinitionVersionsServerTransport { return NewSetDefinitionVersionsServerTransport(&s.srv.SetDefinitionVersionsServer) @@ -111,14 +90,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewSetDefinitionsServerTransport(&s.srv.SetDefinitionsServer) }) resp, err = s.trSetDefinitionsServer.Do(req) - case "VariableValuesClient": - initServer(s, &s.trVariableValuesServer, func() *VariableValuesServerTransport { - return NewVariableValuesServerTransport(&s.srv.VariableValuesServer) - }) - resp, err = s.trVariableValuesServer.Do(req) - case "VariablesClient": - initServer(s, &s.trVariablesServer, func() *VariablesServerTransport { return NewVariablesServerTransport(&s.srv.VariablesServer) }) - resp, err = s.trVariablesServer.Do(req) + case "TokensClient": + initServer(s, &s.trTokensServer, func() *TokensServerTransport { return NewTokensServerTransport(&s.srv.TokensServer) }) + resp, err = s.trTokensServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go index 1c6f463148f5..21e285218141 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -153,7 +152,7 @@ func (s *SetDefinitionsServerTransport) dispatchCreateOrUpdate(req *http.Request const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.SetDefinition](req) @@ -186,7 +185,7 @@ func (s *SetDefinitionsServerTransport) dispatchCreateOrUpdateAtManagementGroup( const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.SetDefinition](req) @@ -223,7 +222,7 @@ func (s *SetDefinitionsServerTransport) dispatchDelete(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) @@ -252,7 +251,7 @@ func (s *SetDefinitionsServerTransport) dispatchDeleteAtManagementGroup(req *htt const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) @@ -285,7 +284,7 @@ func (s *SetDefinitionsServerTransport) dispatchGet(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -326,7 +325,7 @@ func (s *SetDefinitionsServerTransport) dispatchGetAtManagementGroup(req *http.R const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -371,7 +370,7 @@ func (s *SetDefinitionsServerTransport) dispatchGetBuiltIn(req *http.Request) (* const regexStr = `/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -414,7 +413,7 @@ func (s *SetDefinitionsServerTransport) dispatchNewListPager(req *http.Request) const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -540,7 +539,7 @@ func (s *SetDefinitionsServerTransport) dispatchNewListByManagementGroupPager(re const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() diff --git a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go index 790646c54d9c..58e15f298f7f 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -171,7 +170,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchCreateOrUpdate(req *http. const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.SetDefinitionVersion](req) @@ -208,7 +207,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchCreateOrUpdateAtManagemen const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armpolicy.SetDefinitionVersion](req) @@ -249,7 +248,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchDelete(req *http.Request) const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) @@ -282,7 +281,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchDeleteAtManagementGroup(r const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) @@ -319,7 +318,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchGet(req *http.Request) (* const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -364,7 +363,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchGetAtManagementGroup(req const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -413,7 +412,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchGetBuiltIn(req *http.Requ const regexStr = `/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -460,7 +459,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchNewListPager(req *http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -522,7 +521,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchListAll(req *http.Request const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicySetDefinitionVersions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } respr, errRespr := s.srv.ListAll(req.Context(), nil) @@ -547,7 +546,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchListAllAtManagementGroup( const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicySetDefinitionVersions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) @@ -597,7 +596,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchNewListBuiltInPager(req * const regexStr = `/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -661,7 +660,7 @@ func (s *SetDefinitionVersionsServerTransport) dispatchNewListByManagementGroupP const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() diff --git a/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go deleted file mode 100644 index 7691a451714b..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) - -const ( - utcDateTime = "2006-01-02T15:04:05.999999999" - utcDateTimeJSON = `"` + utcDateTime + `"` - utcDateTimeNoT = "2006-01-02 15:04:05.999999999" - utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` - dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` - dateTimeJSON = `"` + time.RFC3339Nano + `"` - dateTimeJSONNoT = `"` + dateTimeNoT + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = dateTimeJSON - } else if tzOffset { - layout = dateTimeJSONNoT - } else if hasT { - layout = utcDateTimeJSON - } else { - layout = utcDateTimeJSONNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - if len(data) == 0 { - return nil - } - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = time.RFC3339Nano - } else if tzOffset { - layout = dateTimeNoT - } else if hasT { - layout = utcDateTime - } else { - layout = utcDateTimeNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func (t dateTimeRFC3339) String() string { - return time.Time(t).Format(time.RFC3339Nano) -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || string(data) == "null" { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/tokens_server.go b/sdk/resourcemanager/resources/armpolicy/fake/tokens_server.go new file mode 100644 index 000000000000..140c7253e3ae --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/fake/tokens_server.go @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "net/http" + "net/url" + "regexp" +) + +// TokensServer is a fake server for instances of the armpolicy.TokensClient type. +type TokensServer struct { + // Acquire is the fake for method TokensClient.Acquire + // HTTP status codes to indicate success: http.StatusOK + Acquire func(ctx context.Context, parameters armpolicy.TokenRequest, options *armpolicy.TokensClientAcquireOptions) (resp azfake.Responder[armpolicy.TokensClientAcquireResponse], errResp azfake.ErrorResponder) + + // AcquireAtManagementGroup is the fake for method TokensClient.AcquireAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + AcquireAtManagementGroup func(ctx context.Context, managementGroupName string, parameters armpolicy.TokenRequest, options *armpolicy.TokensClientAcquireAtManagementGroupOptions) (resp azfake.Responder[armpolicy.TokensClientAcquireAtManagementGroupResponse], errResp azfake.ErrorResponder) +} + +// NewTokensServerTransport creates a new instance of TokensServerTransport with the provided implementation. +// The returned TokensServerTransport instance is connected to an instance of armpolicy.TokensClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTokensServerTransport(srv *TokensServer) *TokensServerTransport { + return &TokensServerTransport{srv: srv} +} + +// TokensServerTransport connects instances of armpolicy.TokensClient to instances of TokensServer. +// Don't use this type directly, use NewTokensServerTransport instead. +type TokensServerTransport struct { + srv *TokensServer +} + +// Do implements the policy.Transporter interface for TokensServerTransport. +func (t *TokensServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TokensServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if tokensServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tokensServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TokensClient.Acquire": + res.resp, res.err = t.dispatchAcquire(req) + case "TokensClient.AcquireAtManagementGroup": + res.resp, res.err = t.dispatchAcquireAtManagementGroup(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TokensServerTransport) dispatchAcquire(req *http.Request) (*http.Response, error) { + if t.srv.Acquire == nil { + return nil, &nonRetriableError{errors.New("fake for method Acquire not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/acquirePolicyToken` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.TokenRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Acquire(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TokenResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TokensServerTransport) dispatchAcquireAtManagementGroup(req *http.Request) (*http.Response, error) { + if t.srv.AcquireAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method AcquireAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/acquirePolicyToken` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.TokenRequest](req) + if err != nil { + return nil, err + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.AcquireAtManagementGroup(req.Context(), managementGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TokenResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TokensServerTransport +var tokensServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go b/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go deleted file mode 100644 index 356e862082cd..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go +++ /dev/null @@ -1,402 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// VariablesServer is a fake server for instances of the armpolicy.VariablesClient type. -type VariablesServer struct { - // CreateOrUpdate is the fake for method VariablesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, variableName string, parameters armpolicy.Variable, options *armpolicy.VariablesClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.VariablesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // CreateOrUpdateAtManagementGroup is the fake for method VariablesClient.CreateOrUpdateAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, parameters armpolicy.Variable, options *armpolicy.VariablesClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method VariablesClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, variableName string, options *armpolicy.VariablesClientDeleteOptions) (resp azfake.Responder[armpolicy.VariablesClientDeleteResponse], errResp azfake.ErrorResponder) - - // DeleteAtManagementGroup is the fake for method VariablesClient.DeleteAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, options *armpolicy.VariablesClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VariablesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, variableName string, options *armpolicy.VariablesClientGetOptions) (resp azfake.Responder[armpolicy.VariablesClientGetResponse], errResp azfake.ErrorResponder) - - // GetAtManagementGroup is the fake for method VariablesClient.GetAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, options *armpolicy.VariablesClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method VariablesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.VariablesClientListOptions) (resp azfake.PagerResponder[armpolicy.VariablesClientListResponse]) - - // NewListForManagementGroupPager is the fake for method VariablesClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, options *armpolicy.VariablesClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]) -} - -// NewVariablesServerTransport creates a new instance of VariablesServerTransport with the provided implementation. -// The returned VariablesServerTransport instance is connected to an instance of armpolicy.VariablesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVariablesServerTransport(srv *VariablesServer) *VariablesServerTransport { - return &VariablesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.VariablesClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]](), - } -} - -// VariablesServerTransport connects instances of armpolicy.VariablesClient to instances of VariablesServer. -// Don't use this type directly, use NewVariablesServerTransport instead. -type VariablesServerTransport struct { - srv *VariablesServer - newListPager *tracker[azfake.PagerResponder[armpolicy.VariablesClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]] -} - -// Do implements the policy.Transporter interface for VariablesServerTransport. -func (v *VariablesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return v.dispatchToMethodFake(req, method) -} - -func (v *VariablesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if variablesServerTransportInterceptor != nil { - res.resp, res.err, intercepted = variablesServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "VariablesClient.CreateOrUpdate": - res.resp, res.err = v.dispatchCreateOrUpdate(req) - case "VariablesClient.CreateOrUpdateAtManagementGroup": - res.resp, res.err = v.dispatchCreateOrUpdateAtManagementGroup(req) - case "VariablesClient.Delete": - res.resp, res.err = v.dispatchDelete(req) - case "VariablesClient.DeleteAtManagementGroup": - res.resp, res.err = v.dispatchDeleteAtManagementGroup(req) - case "VariablesClient.Get": - res.resp, res.err = v.dispatchGet(req) - case "VariablesClient.GetAtManagementGroup": - res.resp, res.err = v.dispatchGetAtManagementGroup(req) - case "VariablesClient.NewListPager": - res.resp, res.err = v.dispatchNewListPager(req) - case "VariablesClient.NewListForManagementGroupPager": - res.resp, res.err = v.dispatchNewListForManagementGroupPager(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (v *VariablesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Variable](req) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdate(req.Context(), variableNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdateAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Variable](req) - if err != nil { - return nil, err - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if v.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Delete(req.Context(), variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.DeleteAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method DeleteAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.GetAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := v.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resp := v.srv.NewListPager(nil) - newListPager = &resp - v.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.VariablesClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - v.newListPager.remove(req) - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := v.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListForManagementGroupPager(managementGroupIDParam, nil) - newListForManagementGroupPager = &resp - v.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.VariablesClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - v.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to VariablesServerTransport -var variablesServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go b/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go deleted file mode 100644 index d9e5f5ed0c31..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go +++ /dev/null @@ -1,434 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// VariableValuesServer is a fake server for instances of the armpolicy.VariableValuesClient type. -type VariableValuesServer struct { - // CreateOrUpdate is the fake for method VariableValuesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, variableName string, variableValueName string, parameters armpolicy.VariableValue, options *armpolicy.VariableValuesClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.VariableValuesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // CreateOrUpdateAtManagementGroup is the fake for method VariableValuesClient.CreateOrUpdateAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters armpolicy.VariableValue, options *armpolicy.VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method VariableValuesClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, variableName string, variableValueName string, options *armpolicy.VariableValuesClientDeleteOptions) (resp azfake.Responder[armpolicy.VariableValuesClientDeleteResponse], errResp azfake.ErrorResponder) - - // DeleteAtManagementGroup is the fake for method VariableValuesClient.DeleteAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *armpolicy.VariableValuesClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VariableValuesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, variableName string, variableValueName string, options *armpolicy.VariableValuesClientGetOptions) (resp azfake.Responder[armpolicy.VariableValuesClientGetResponse], errResp azfake.ErrorResponder) - - // GetAtManagementGroup is the fake for method VariableValuesClient.GetAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *armpolicy.VariableValuesClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method VariableValuesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(variableName string, options *armpolicy.VariableValuesClientListOptions) (resp azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]) - - // NewListForManagementGroupPager is the fake for method VariableValuesClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, variableName string, options *armpolicy.VariableValuesClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]) -} - -// NewVariableValuesServerTransport creates a new instance of VariableValuesServerTransport with the provided implementation. -// The returned VariableValuesServerTransport instance is connected to an instance of armpolicy.VariableValuesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVariableValuesServerTransport(srv *VariableValuesServer) *VariableValuesServerTransport { - return &VariableValuesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]](), - } -} - -// VariableValuesServerTransport connects instances of armpolicy.VariableValuesClient to instances of VariableValuesServer. -// Don't use this type directly, use NewVariableValuesServerTransport instead. -type VariableValuesServerTransport struct { - srv *VariableValuesServer - newListPager *tracker[azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]] -} - -// Do implements the policy.Transporter interface for VariableValuesServerTransport. -func (v *VariableValuesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return v.dispatchToMethodFake(req, method) -} - -func (v *VariableValuesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if variableValuesServerTransportInterceptor != nil { - res.resp, res.err, intercepted = variableValuesServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "VariableValuesClient.CreateOrUpdate": - res.resp, res.err = v.dispatchCreateOrUpdate(req) - case "VariableValuesClient.CreateOrUpdateAtManagementGroup": - res.resp, res.err = v.dispatchCreateOrUpdateAtManagementGroup(req) - case "VariableValuesClient.Delete": - res.resp, res.err = v.dispatchDelete(req) - case "VariableValuesClient.DeleteAtManagementGroup": - res.resp, res.err = v.dispatchDeleteAtManagementGroup(req) - case "VariableValuesClient.Get": - res.resp, res.err = v.dispatchGet(req) - case "VariableValuesClient.GetAtManagementGroup": - res.resp, res.err = v.dispatchGetAtManagementGroup(req) - case "VariableValuesClient.NewListPager": - res.resp, res.err = v.dispatchNewListPager(req) - case "VariableValuesClient.NewListForManagementGroupPager": - res.resp, res.err = v.dispatchNewListForManagementGroupPager(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (v *VariableValuesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.VariableValue](req) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdate(req.Context(), variableNameParam, variableValueNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdateAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.VariableValue](req) - if err != nil { - return nil, err - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if v.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Delete(req.Context(), variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.DeleteAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method DeleteAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.GetAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := v.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListPager(variableNameParam, nil) - newListPager = &resp - v.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.VariableValuesClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - v.newListPager.remove(req) - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := v.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListForManagementGroupPager(managementGroupIDParam, variableNameParam, nil) - newListForManagementGroupPager = &resp - v.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.VariableValuesClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - v.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to VariableValuesServerTransport -var variableValuesServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index 46755e671ac0..53c31c0d7e9d 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -3,7 +3,7 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy go 1.24.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 @@ -14,14 +14,14 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.3.0 // indirect + github.com/golang-jwt/jwt/v5 v5.3.1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.45.0 // indirect - golang.org/x/net v0.47.0 // indirect - golang.org/x/sys v0.38.0 // indirect - golang.org/x/text v0.31.0 // indirect + golang.org/x/crypto v0.47.0 // indirect + golang.org/x/net v0.49.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/text v0.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/resources/armpolicy/go.sum b/sdk/resourcemanager/resources/armpolicy/go.sum index cc236fb92e86..9a3463cfdc1d 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.sum +++ b/sdk/resourcemanager/resources/armpolicy/go.sum @@ -1,5 +1,5 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 h1:JXg2dwJUmPB9JmtVmdEB16APJ7jurfbY5jnfXpJoRMc= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= @@ -20,8 +20,8 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgv github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= -github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU= @@ -40,15 +40,15 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= -golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= +golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sdk/resourcemanager/resources/armpolicy/models.go b/sdk/resourcemanager/resources/armpolicy/models.go index 9d744706b094..b7891b9bfa89 100644 --- a/sdk/resourcemanager/resources/armpolicy/models.go +++ b/sdk/resourcemanager/resources/armpolicy/models.go @@ -1,68 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy import "time" -// Alias - The alias type. -type Alias struct { - // The default path for an alias. - DefaultPath *string - - // The default pattern for an alias. - DefaultPattern *AliasPattern - - // The alias name. - Name *string - - // The paths for an alias. - Paths []*AliasPath - - // The type of the alias. - Type *AliasType - - // READ-ONLY; The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata - DefaultMetadata *AliasPathMetadata -} - -// AliasPath - The type of the paths for alias. -type AliasPath struct { - // The API versions. - APIVersions []*string - - // The path of an alias. - Path *string - - // The pattern for an alias path. - Pattern *AliasPattern - - // READ-ONLY; The metadata of the alias path. If missing, fall back to the default metadata of the alias. - Metadata *AliasPathMetadata -} - -type AliasPathMetadata struct { - // READ-ONLY; The attributes of the token that the alias path is referring to. - Attributes *AliasPathAttributes - - // READ-ONLY; The type of the token that the alias path is referring to. - Type *AliasPathTokenType -} - -// AliasPattern - The type of the pattern for an alias path. -type AliasPattern struct { - // The alias pattern phrase. - Phrase *string - - // The type of alias pattern - Type *AliasPatternType - - // The alias pattern variable. - Variable *string -} - // Assignment - The policy assignment. type Assignment struct { // The managed identity associated with the policy assignment. @@ -74,30 +17,33 @@ type Assignment struct { // Properties for the policy assignment. Properties *AssignmentProperties - // READ-ONLY; The ID of the policy assignment. + // 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 policy assignment. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata relating to this resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the policy assignment. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// AssignmentListResult - List of policy assignments. +// AssignmentListResult - The response of a PolicyAssignment list operation. type AssignmentListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of policy assignments. + // REQUIRED; The PolicyAssignment items on this page Value []*Assignment + + // The link to the next page of items + NextLink *string } // AssignmentProperties - The policy assignment properties. 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 @@ -107,7 +53,7 @@ type AssignmentProperties struct { // The display name of the policy assignment. DisplayName *string - // The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. + // 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. @@ -135,6 +81,10 @@ type AssignmentProperties struct { // 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 @@ -164,104 +114,21 @@ type AssignmentUpdateProperties struct { ResourceSelectors []*ResourceSelector } -// DataEffect - The data effect definition. -type DataEffect struct { - // The data effect details schema. - DetailsSchema any - - // The data effect name. - Name *string -} - -// DataManifestCustomResourceFunctionDefinition - The custom resource function definition. -type DataManifestCustomResourceFunctionDefinition struct { - // A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified - // in the policy rule eg - vault('2019-06-01'). - AllowCustomProperties *bool - - // The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and - // vault().location are supported - DefaultProperties []*string - - // The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - FullyQualifiedResourceType *string - - // The function name as it will appear in the policy rule. eg - 'vault'. - Name *string -} - -// DataManifestResourceFunctionsDefinition - The resource functions supported by a manifest -type DataManifestResourceFunctionsDefinition struct { - // An array of data manifest custom resource definition. - Custom []*DataManifestCustomResourceFunctionDefinition - - // The standard resource functions (subscription and/or resourceGroup). - Standard []*string -} - -// DataPolicyManifest - The data policy manifest. -type DataPolicyManifest struct { - // The data policy manifest properties. - Properties *DataPolicyManifestProperties - - // READ-ONLY; The ID of the data policy manifest. - ID *string - - // READ-ONLY; The name of the data policy manifest (it's the same as the Policy Mode). - Name *string - - // READ-ONLY; The type of the resource (Microsoft.Authorization/dataPolicyManifests). - Type *string -} - -// DataPolicyManifestListResult - List of data policy manifests. -type DataPolicyManifestListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of data policy manifests. - Value []*DataPolicyManifest -} - -// DataPolicyManifestProperties - The properties of the data policy manifest. -type DataPolicyManifestProperties struct { - // The effect definition. - Effects []*DataEffect - - // The non-alias field accessor values that can be used in the policy rule. - FieldValues []*string - - // A value indicating whether policy mode is allowed only in built-in definitions. - IsBuiltInOnly *bool - - // The list of namespaces for the data policy manifest. - Namespaces []*string - - // The policy mode of the data policy manifest. - PolicyMode *string - - // The resource functions definition specified in the data manifest. - ResourceFunctions *DataManifestResourceFunctionsDefinition - - // An array of resource type aliases. - ResourceTypeAliases []*ResourceTypeAliases -} - // Definition - The policy definition. type Definition struct { // The policy definition properties. Properties *DefinitionProperties - // READ-ONLY; The ID of the policy definition. + // 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 policy definition. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata relating to this resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions). + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -283,13 +150,13 @@ type DefinitionGroup struct { DisplayName *string } -// DefinitionListResult - List of policy definitions. +// DefinitionListResult - The response of a PolicyDefinition list operation. type DefinitionListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of policy definitions. + // REQUIRED; The PolicyDefinition items on this page Value []*Definition + + // The link to the next page of items + NextLink *string } // DefinitionProperties - The policy definition properties. @@ -300,6 +167,9 @@ type DefinitionProperties struct { // 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 @@ -353,26 +223,26 @@ type DefinitionVersion struct { // The policy definition version properties. Properties *DefinitionVersionProperties - // READ-ONLY; The ID of the policy definition version. + // 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 policy definition version. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata relating to this resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions/versions). + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// DefinitionVersionListResult - List of policy definition versions. +// DefinitionVersionListResult - The response of a PolicyDefinitionVersion list operation. type DefinitionVersionListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of policy definitions versions. + // REQUIRED; The PolicyDefinitionVersion items on this page Value []*DefinitionVersion + + // The link to the next page of items + NextLink *string } // DefinitionVersionProperties - The policy definition properties. @@ -383,6 +253,9 @@ type DefinitionVersionProperties struct { // 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 @@ -402,76 +275,52 @@ type DefinitionVersionProperties struct { Version *string } -// Exemption - The policy exemption. -type Exemption struct { - // REQUIRED; Properties for the policy exemption. - Properties *ExemptionProperties +// ExternalEvaluationEndpointInvocationResult - The external evaluation endpoint invocation results. +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 - // READ-ONLY; The ID of the policy exemption. - ID *string - - // READ-ONLY; The name of the policy exemption. - Name *string + // The expiration of the results. + Expiration *time.Time - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData + // The status message with additional details about the invocation result. + Message *string - // READ-ONLY; The type of the resource (Microsoft.Authorization/policyExemptions). - Type *string -} + // The details of the policy requiring the external endpoint invocation. + PolicyInfo *LogInfo -// ExemptionListResult - List of policy exemptions. -type ExemptionListResult struct { - // An array of policy exemptions. - Value []*Exemption + // The result of the external endpoint. Possible values are Succeeded and Failed. + Result *ExternalEndpointResult - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string + // The date and time after which a failed endpoint invocation can be retried. + RetryAfter *time.Time } -// ExemptionProperties - The policy exemption properties. -type ExemptionProperties struct { - // REQUIRED; The policy exemption category. Possible values are Waiver and Mitigated. - ExemptionCategory *ExemptionCategory - - // REQUIRED; The ID of the policy assignment that is being exempted. - PolicyAssignmentID *string - - // The option whether validate the exemption is at or under the assignment scope. - AssignmentScopeValidation *AssignmentScopeValidation - - // The description of the policy exemption. - Description *string - - // The display name of the policy exemption. - DisplayName *string - - // The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy exemption. - ExpiresOn *time.Time - - // The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - Metadata any +// ExternalEvaluationEndpointSettings - The settings of an external endpoint providing evaluation results. +type ExternalEvaluationEndpointSettings struct { + // The details of the endpoint. + Details any - // The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - PolicyDefinitionReferenceIDs []*string - - // The resource selector list to filter policies by resource properties. - ResourceSelectors []*ResourceSelector + // The kind of the endpoint. + Kind *string } -// ExemptionUpdate - The policy exemption for Patch request. -type ExemptionUpdate struct { - // The policy exemption properties for Patch request. - Properties *ExemptionUpdateProperties -} +// ExternalEvaluationEnforcementSettings - The details of the source of external evaluation results required by the policy +// during enforcement evaluation. +type ExternalEvaluationEnforcementSettings struct { + // The settings of an external endpoint providing evaluation results. + EndpointSettings *ExternalEvaluationEndpointSettings -// ExemptionUpdateProperties - The policy exemption properties for Patch request. -type ExemptionUpdateProperties struct { - // The option whether validate the exemption is at or under the assignment scope. - AssignmentScopeValidation *AssignmentScopeValidation + // 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 resource selector list to filter policies by resource properties. - ResourceSelectors []*ResourceSelector + // 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 } // Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity @@ -481,8 +330,7 @@ type Identity struct { 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}'. + // 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 @@ -492,6 +340,72 @@ type Identity struct { TenantID *string } +// LogInfo - The policy log info. +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 +} + // 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. type NonComplianceMessage struct { @@ -500,8 +414,8 @@ type NonComplianceMessage struct { 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. + // 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 } @@ -529,8 +443,8 @@ type ParameterDefinitionsValue struct { 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/. + // 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. @@ -539,12 +453,10 @@ type ParameterDefinitionsValue struct { // ParameterDefinitionsValueMetadata - General metadata for the parameter. type ParameterDefinitionsValueMetadata struct { - // OPTIONAL; Contains additional key/value pairs not defined in the schema. 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. + // policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. AssignPermissions *bool // The description of the parameter. @@ -573,15 +485,6 @@ type ResourceSelector struct { Selectors []*Selector } -// ResourceTypeAliases - The resource type aliases definition. -type ResourceTypeAliases struct { - // The aliases for property names. - Aliases []*Alias - - // The resource type name. - ResourceType *string -} - // Selector - The selector expression. type Selector struct { // The list of values to filter in. @@ -599,26 +502,26 @@ type SetDefinition struct { // The policy set definition properties. Properties *SetDefinitionProperties - // READ-ONLY; The ID of the policy set definition. + // 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 policy set definition. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata relating to this resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions). + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// SetDefinitionListResult - List of policy set definitions. +// SetDefinitionListResult - The response of a PolicySetDefinition list operation. type SetDefinitionListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of policy set definitions. + // REQUIRED; The PolicySetDefinition items on this page Value []*SetDefinition + + // The link to the next page of items + NextLink *string } // SetDefinitionProperties - The policy set definition properties. @@ -656,26 +559,26 @@ type SetDefinitionVersion struct { // The policy set definition version properties. Properties *SetDefinitionVersionProperties - // READ-ONLY; The ID of the policy set definition version. + // 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 policy set definition version. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata relating to this resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions/versions). + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// SetDefinitionVersionListResult - List of policy set definition versions. +// SetDefinitionVersionListResult - The response of a PolicySetDefinitionVersion list operation. type SetDefinitionVersionListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of policy set definition versions. + // REQUIRED; The PolicySetDefinitionVersion items on this page Value []*SetDefinitionVersion + + // The link to the next page of items + NextLink *string } // SetDefinitionVersionProperties - The policy set definition properties. @@ -726,91 +629,58 @@ type SystemData struct { LastModifiedByType *CreatedByType } -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 -} - -// Variable - The variable. -type Variable struct { - // REQUIRED; Properties for the variable. - Properties *VariableProperties - - // READ-ONLY; The ID of the variable. - ID *string - - // READ-ONLY; The name of the variable. - Name *string - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData +// TokenOperation - The resource operation to acquire a token for. +type TokenOperation struct { + // REQUIRED; The http method of the resource operation. + HTTPMethod *string - // READ-ONLY; The type of the resource (Microsoft.Authorization/variables). - Type *string -} + // REQUIRED; The request URI of the resource operation. + URI *string -// VariableColumn - The variable column. -type VariableColumn struct { - // REQUIRED; The name of this policy variable column. - ColumnName *string + // The payload of the resource operation. + Content any } -// VariableListResult - List of variables. -type VariableListResult struct { - // An array of variables. - Value []*Variable +// TokenRequest - The policy token request properties. +type TokenRequest struct { + // REQUIRED; The resource operation to acquire a token for. + Operation *TokenOperation - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string + // The change reference. + ChangeReference *string } -// VariableProperties - The variable properties. -type VariableProperties struct { - // REQUIRED; Variable column definitions. - Columns []*VariableColumn -} +// TokenResponse - The policy token response properties. +type TokenResponse struct { + // The change reference associated with the operation for which the token is acquired. + ChangeReference *string -// VariableValue - The variable value. -type VariableValue struct { - // REQUIRED; Properties for the variable value. - Properties *VariableValueProperties + // The expiration of the policy token. + Expiration *time.Time - // READ-ONLY; The ID of the variable. - ID *string + // Status message with additional details about the token acquisition operation result. + Message *string - // READ-ONLY; The name of the variable. - Name *string + // The result of the completed token acquisition operation. Possible values are Succeeded and Failed. + Result *PolicyTokenResult - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData + // An array of external evaluation endpoint invocation results. + Results []*ExternalEvaluationEndpointInvocationResult - // READ-ONLY; The type of the resource (Microsoft.Authorization/variables/values). - Type *string -} + // 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 -// VariableValueColumnValue - The name value tuple for this variable value column. -type VariableValueColumnValue struct { - // REQUIRED; Column name for the variable value - ColumnName *string + // The issued policy token. + Token *string - // REQUIRED; Column value for the variable value; this can be an integer, double, boolean, null or a string. - ColumnValue any + // The unique Id assigned to the policy token. + TokenID *string } -// VariableValueListResult - List of variable values. -type VariableValueListResult struct { - // An array of variable values. - Value []*VariableValue - - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string -} +type UserAssignedIdentitiesValue struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string -// VariableValueProperties - The variable value properties. -type VariableValueProperties struct { - // REQUIRED; Variable value column value array. - Values []*VariableValueColumnValue + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string } diff --git a/sdk/resourcemanager/resources/armpolicy/models_serde.go b/sdk/resourcemanager/resources/armpolicy/models_serde.go index 9dbeeb0619db..59d6ec6b6a18 100644 --- a/sdk/resourcemanager/resources/armpolicy/models_serde.go +++ b/sdk/resourcemanager/resources/armpolicy/models_serde.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -9,161 +8,11 @@ import ( "encoding/json" "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime" "reflect" + "time" ) -// MarshalJSON implements the json.Marshaller interface for type Alias. -func (a Alias) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "defaultMetadata", a.DefaultMetadata) - populate(objectMap, "defaultPath", a.DefaultPath) - populate(objectMap, "defaultPattern", a.DefaultPattern) - populate(objectMap, "name", a.Name) - populate(objectMap, "paths", a.Paths) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Alias. -func (a *Alias) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "defaultMetadata": - err = unpopulate(val, "DefaultMetadata", &a.DefaultMetadata) - delete(rawMsg, key) - case "defaultPath": - err = unpopulate(val, "DefaultPath", &a.DefaultPath) - delete(rawMsg, key) - case "defaultPattern": - err = unpopulate(val, "DefaultPattern", &a.DefaultPattern) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) - case "paths": - err = unpopulate(val, "Paths", &a.Paths) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AliasPath. -func (a AliasPath) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "apiVersions", a.APIVersions) - populate(objectMap, "metadata", a.Metadata) - populate(objectMap, "path", a.Path) - populate(objectMap, "pattern", a.Pattern) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPath. -func (a *AliasPath) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "apiVersions": - err = unpopulate(val, "APIVersions", &a.APIVersions) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &a.Metadata) - delete(rawMsg, key) - case "path": - err = unpopulate(val, "Path", &a.Path) - delete(rawMsg, key) - case "pattern": - err = unpopulate(val, "Pattern", &a.Pattern) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AliasPathMetadata. -func (a AliasPathMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "attributes", a.Attributes) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPathMetadata. -func (a *AliasPathMetadata) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "attributes": - err = unpopulate(val, "Attributes", &a.Attributes) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AliasPattern. -func (a AliasPattern) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "phrase", a.Phrase) - populate(objectMap, "type", a.Type) - populate(objectMap, "variable", a.Variable) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPattern. -func (a *AliasPattern) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "phrase": - err = unpopulate(val, "Phrase", &a.Phrase) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - case "variable": - err = unpopulate(val, "Variable", &a.Variable) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Assignment. func (a Assignment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -249,11 +98,13 @@ func (a *AssignmentListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssignmentProperties. func (a AssignmentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "assignmentType", a.AssignmentType) populate(objectMap, "definitionVersion", a.DefinitionVersion) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "effectiveDefinitionVersion", a.EffectiveDefinitionVersion) populate(objectMap, "enforcementMode", a.EnforcementMode) + populate(objectMap, "instanceId", a.InstanceID) populate(objectMap, "latestDefinitionVersion", a.LatestDefinitionVersion) populateAny(objectMap, "metadata", a.Metadata) populate(objectMap, "nonComplianceMessages", a.NonComplianceMessages) @@ -275,6 +126,9 @@ func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "assignmentType": + err = unpopulate(val, "AssignmentType", &a.AssignmentType) + delete(rawMsg, key) case "definitionVersion": err = unpopulate(val, "DefinitionVersion", &a.DefinitionVersion) delete(rawMsg, key) @@ -290,6 +144,9 @@ func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { case "enforcementMode": err = unpopulate(val, "EnforcementMode", &a.EnforcementMode) delete(rawMsg, key) + case "instanceId": + err = unpopulate(val, "InstanceID", &a.InstanceID) + delete(rawMsg, key) case "latestDefinitionVersion": err = unpopulate(val, "LatestDefinitionVersion", &a.LatestDefinitionVersion) delete(rawMsg, key) @@ -391,228 +248,6 @@ func (a *AssignmentUpdateProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DataEffect. -func (d DataEffect) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "detailsSchema", d.DetailsSchema) - populate(objectMap, "name", d.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataEffect. -func (d *DataEffect) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "detailsSchema": - err = unpopulate(val, "DetailsSchema", &d.DetailsSchema) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DataManifestCustomResourceFunctionDefinition. -func (d DataManifestCustomResourceFunctionDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "allowCustomProperties", d.AllowCustomProperties) - populate(objectMap, "defaultProperties", d.DefaultProperties) - populate(objectMap, "fullyQualifiedResourceType", d.FullyQualifiedResourceType) - populate(objectMap, "name", d.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestCustomResourceFunctionDefinition. -func (d *DataManifestCustomResourceFunctionDefinition) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "allowCustomProperties": - err = unpopulate(val, "AllowCustomProperties", &d.AllowCustomProperties) - delete(rawMsg, key) - case "defaultProperties": - err = unpopulate(val, "DefaultProperties", &d.DefaultProperties) - delete(rawMsg, key) - case "fullyQualifiedResourceType": - err = unpopulate(val, "FullyQualifiedResourceType", &d.FullyQualifiedResourceType) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DataManifestResourceFunctionsDefinition. -func (d DataManifestResourceFunctionsDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "custom", d.Custom) - populate(objectMap, "standard", d.Standard) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestResourceFunctionsDefinition. -func (d *DataManifestResourceFunctionsDefinition) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "custom": - err = unpopulate(val, "Custom", &d.Custom) - delete(rawMsg, key) - case "standard": - err = unpopulate(val, "Standard", &d.Standard) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DataPolicyManifest. -func (d DataPolicyManifest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", d.ID) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifest. -func (d *DataPolicyManifest) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DataPolicyManifestListResult. -func (d DataPolicyManifestListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestListResult. -func (d *DataPolicyManifestListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DataPolicyManifestProperties. -func (d DataPolicyManifestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "effects", d.Effects) - populate(objectMap, "fieldValues", d.FieldValues) - populate(objectMap, "isBuiltInOnly", d.IsBuiltInOnly) - populate(objectMap, "namespaces", d.Namespaces) - populate(objectMap, "policyMode", d.PolicyMode) - populate(objectMap, "resourceFunctions", d.ResourceFunctions) - populate(objectMap, "resourceTypeAliases", d.ResourceTypeAliases) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestProperties. -func (d *DataPolicyManifestProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "effects": - err = unpopulate(val, "Effects", &d.Effects) - delete(rawMsg, key) - case "fieldValues": - err = unpopulate(val, "FieldValues", &d.FieldValues) - delete(rawMsg, key) - case "isBuiltInOnly": - err = unpopulate(val, "IsBuiltInOnly", &d.IsBuiltInOnly) - delete(rawMsg, key) - case "namespaces": - err = unpopulate(val, "Namespaces", &d.Namespaces) - delete(rawMsg, key) - case "policyMode": - err = unpopulate(val, "PolicyMode", &d.PolicyMode) - delete(rawMsg, key) - case "resourceFunctions": - err = unpopulate(val, "ResourceFunctions", &d.ResourceFunctions) - delete(rawMsg, key) - case "resourceTypeAliases": - err = unpopulate(val, "ResourceTypeAliases", &d.ResourceTypeAliases) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Definition. func (d Definition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -735,6 +370,7 @@ func (d DefinitionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", d.Description) populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "externalEvaluationEnforcementSettings", d.ExternalEvaluationEnforcementSettings) populateAny(objectMap, "metadata", d.Metadata) populate(objectMap, "mode", d.Mode) populate(objectMap, "parameters", d.Parameters) @@ -760,6 +396,9 @@ func (d *DefinitionProperties) UnmarshalJSON(data []byte) error { case "displayName": err = unpopulate(val, "DisplayName", &d.DisplayName) delete(rawMsg, key) + case "externalEvaluationEnforcementSettings": + err = unpopulate(val, "ExternalEvaluationEnforcementSettings", &d.ExternalEvaluationEnforcementSettings) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &d.Metadata) delete(rawMsg, key) @@ -919,147 +558,74 @@ func (d DefinitionVersionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", d.Description) populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "externalEvaluationEnforcementSettings", d.ExternalEvaluationEnforcementSettings) populateAny(objectMap, "metadata", d.Metadata) populate(objectMap, "mode", d.Mode) populate(objectMap, "parameters", d.Parameters) - populateAny(objectMap, "policyRule", d.PolicyRule) - populate(objectMap, "policyType", d.PolicyType) - populate(objectMap, "version", d.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersionProperties. -func (d *DefinitionVersionProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "description": - err = unpopulate(val, "Description", &d.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &d.DisplayName) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) - case "mode": - err = unpopulate(val, "Mode", &d.Mode) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &d.Parameters) - delete(rawMsg, key) - case "policyRule": - err = unpopulate(val, "PolicyRule", &d.PolicyRule) - delete(rawMsg, key) - case "policyType": - err = unpopulate(val, "PolicyType", &d.PolicyType) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Exemption. -func (e Exemption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Exemption. -func (e *Exemption) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &e.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &e.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &e.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExemptionListResult. -func (e ExemptionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) + populateAny(objectMap, "policyRule", d.PolicyRule) + populate(objectMap, "policyType", d.PolicyType) + populate(objectMap, "version", d.Version) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionListResult. -func (e *ExemptionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersionProperties. +func (d *DefinitionVersionProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) + case "description": + err = unpopulate(val, "Description", &d.Description) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &e.Value) + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + case "externalEvaluationEnforcementSettings": + err = unpopulate(val, "ExternalEvaluationEnforcementSettings", &d.ExternalEvaluationEnforcementSettings) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &d.Metadata) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "policyRule": + err = unpopulate(val, "PolicyRule", &d.PolicyRule) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &d.PolicyType) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionProperties. -func (e ExemptionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEndpointInvocationResult. +func (e ExternalEvaluationEndpointInvocationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) - populate(objectMap, "description", e.Description) - populate(objectMap, "displayName", e.DisplayName) - populate(objectMap, "exemptionCategory", e.ExemptionCategory) - populateDateTimeRFC3339(objectMap, "expiresOn", e.ExpiresOn) - populateAny(objectMap, "metadata", e.Metadata) - populate(objectMap, "policyAssignmentId", e.PolicyAssignmentID) - populate(objectMap, "policyDefinitionReferenceIds", e.PolicyDefinitionReferenceIDs) - populate(objectMap, "resourceSelectors", e.ResourceSelectors) + populateAny(objectMap, "claims", e.Claims) + populateTime[datetime.RFC3339](objectMap, "expiration", e.Expiration) + populate(objectMap, "message", e.Message) + populate(objectMap, "policyInfo", e.PolicyInfo) + populate(objectMap, "result", e.Result) + populateTime[datetime.RFC3339](objectMap, "retryAfter", e.RetryAfter) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionProperties. -func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEndpointInvocationResult. +func (e *ExternalEvaluationEndpointInvocationResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1067,32 +633,23 @@ func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "assignmentScopeValidation": - err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &e.Description) + case "claims": + err = unpopulate(val, "Claims", &e.Claims) delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &e.DisplayName) - delete(rawMsg, key) - case "exemptionCategory": - err = unpopulate(val, "ExemptionCategory", &e.ExemptionCategory) + case "expiration": + err = unpopulateTime[datetime.RFC3339](val, "Expiration", &e.Expiration) delete(rawMsg, key) - case "expiresOn": - err = unpopulateDateTimeRFC3339(val, "ExpiresOn", &e.ExpiresOn) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &e.Metadata) + case "message": + err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) - case "policyAssignmentId": - err = unpopulate(val, "PolicyAssignmentID", &e.PolicyAssignmentID) + case "policyInfo": + err = unpopulate(val, "PolicyInfo", &e.PolicyInfo) delete(rawMsg, key) - case "policyDefinitionReferenceIds": - err = unpopulate(val, "PolicyDefinitionReferenceIDs", &e.PolicyDefinitionReferenceIDs) + case "result": + err = unpopulate(val, "Result", &e.Result) delete(rawMsg, key) - case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + case "retryAfter": + err = unpopulateTime[datetime.RFC3339](val, "RetryAfter", &e.RetryAfter) delete(rawMsg, key) } if err != nil { @@ -1102,15 +659,16 @@ func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionUpdate. -func (e ExemptionUpdate) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEndpointSettings. +func (e ExternalEvaluationEndpointSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", e.Properties) + populateAny(objectMap, "details", e.Details) + populate(objectMap, "kind", e.Kind) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdate. -func (e *ExemptionUpdate) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEndpointSettings. +func (e *ExternalEvaluationEndpointSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1118,8 +676,11 @@ func (e *ExemptionUpdate) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &e.Properties) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) delete(rawMsg, key) } if err != nil { @@ -1129,16 +690,18 @@ func (e *ExemptionUpdate) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionUpdateProperties. -func (e ExemptionUpdateProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEnforcementSettings. +func (e ExternalEvaluationEnforcementSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) - populate(objectMap, "resourceSelectors", e.ResourceSelectors) + populate(objectMap, "endpointSettings", e.EndpointSettings) + populate(objectMap, "missingTokenAction", e.MissingTokenAction) + populate(objectMap, "resultLifespan", e.ResultLifespan) + populate(objectMap, "roleDefinitionIds", e.RoleDefinitionIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdateProperties. -func (e *ExemptionUpdateProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEnforcementSettings. +func (e *ExternalEvaluationEnforcementSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1146,11 +709,17 @@ func (e *ExemptionUpdateProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "assignmentScopeValidation": - err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) + case "endpointSettings": + err = unpopulate(val, "EndpointSettings", &e.EndpointSettings) delete(rawMsg, key) - case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + case "missingTokenAction": + err = unpopulate(val, "MissingTokenAction", &e.MissingTokenAction) + delete(rawMsg, key) + case "resultLifespan": + err = unpopulate(val, "ResultLifespan", &e.ResultLifespan) + delete(rawMsg, key) + case "roleDefinitionIds": + err = unpopulate(val, "RoleDefinitionIDs", &e.RoleDefinitionIDs) delete(rawMsg, key) } if err != nil { @@ -1199,6 +768,113 @@ func (i *Identity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type LogInfo. +func (l LogInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ancestors", l.Ancestors) + populate(objectMap, "complianceReasonCode", l.ComplianceReasonCode) + populate(objectMap, "policyAssignmentDisplayName", l.PolicyAssignmentDisplayName) + populate(objectMap, "policyAssignmentId", l.PolicyAssignmentID) + populate(objectMap, "policyAssignmentName", l.PolicyAssignmentName) + populate(objectMap, "policyAssignmentScope", l.PolicyAssignmentScope) + populate(objectMap, "policyAssignmentVersion", l.PolicyAssignmentVersion) + populate(objectMap, "policyDefinitionDisplayName", l.PolicyDefinitionDisplayName) + populate(objectMap, "policyDefinitionEffect", l.PolicyDefinitionEffect) + populate(objectMap, "policyDefinitionGroupNames", l.PolicyDefinitionGroupNames) + populate(objectMap, "policyDefinitionId", l.PolicyDefinitionID) + populate(objectMap, "policyDefinitionName", l.PolicyDefinitionName) + populate(objectMap, "policyDefinitionReferenceId", l.PolicyDefinitionReferenceID) + populate(objectMap, "policyDefinitionVersion", l.PolicyDefinitionVersion) + populate(objectMap, "policyExemptionIds", l.PolicyExemptionIDs) + populate(objectMap, "policySetDefinitionCategory", l.PolicySetDefinitionCategory) + populate(objectMap, "policySetDefinitionDisplayName", l.PolicySetDefinitionDisplayName) + populate(objectMap, "policySetDefinitionId", l.PolicySetDefinitionID) + populate(objectMap, "policySetDefinitionName", l.PolicySetDefinitionName) + populate(objectMap, "policySetDefinitionVersion", l.PolicySetDefinitionVersion) + populate(objectMap, "resourceLocation", l.ResourceLocation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogInfo. +func (l *LogInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ancestors": + err = unpopulate(val, "Ancestors", &l.Ancestors) + delete(rawMsg, key) + case "complianceReasonCode": + err = unpopulate(val, "ComplianceReasonCode", &l.ComplianceReasonCode) + delete(rawMsg, key) + case "policyAssignmentDisplayName": + err = unpopulate(val, "PolicyAssignmentDisplayName", &l.PolicyAssignmentDisplayName) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &l.PolicyAssignmentID) + delete(rawMsg, key) + case "policyAssignmentName": + err = unpopulate(val, "PolicyAssignmentName", &l.PolicyAssignmentName) + delete(rawMsg, key) + case "policyAssignmentScope": + err = unpopulate(val, "PolicyAssignmentScope", &l.PolicyAssignmentScope) + delete(rawMsg, key) + case "policyAssignmentVersion": + err = unpopulate(val, "PolicyAssignmentVersion", &l.PolicyAssignmentVersion) + delete(rawMsg, key) + case "policyDefinitionDisplayName": + err = unpopulate(val, "PolicyDefinitionDisplayName", &l.PolicyDefinitionDisplayName) + delete(rawMsg, key) + case "policyDefinitionEffect": + err = unpopulate(val, "PolicyDefinitionEffect", &l.PolicyDefinitionEffect) + delete(rawMsg, key) + case "policyDefinitionGroupNames": + err = unpopulate(val, "PolicyDefinitionGroupNames", &l.PolicyDefinitionGroupNames) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &l.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionName": + err = unpopulate(val, "PolicyDefinitionName", &l.PolicyDefinitionName) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &l.PolicyDefinitionReferenceID) + delete(rawMsg, key) + case "policyDefinitionVersion": + err = unpopulate(val, "PolicyDefinitionVersion", &l.PolicyDefinitionVersion) + delete(rawMsg, key) + case "policyExemptionIds": + err = unpopulate(val, "PolicyExemptionIDs", &l.PolicyExemptionIDs) + delete(rawMsg, key) + case "policySetDefinitionCategory": + err = unpopulate(val, "PolicySetDefinitionCategory", &l.PolicySetDefinitionCategory) + delete(rawMsg, key) + case "policySetDefinitionDisplayName": + err = unpopulate(val, "PolicySetDefinitionDisplayName", &l.PolicySetDefinitionDisplayName) + delete(rawMsg, key) + case "policySetDefinitionId": + err = unpopulate(val, "PolicySetDefinitionID", &l.PolicySetDefinitionID) + delete(rawMsg, key) + case "policySetDefinitionName": + err = unpopulate(val, "PolicySetDefinitionName", &l.PolicySetDefinitionName) + delete(rawMsg, key) + case "policySetDefinitionVersion": + err = unpopulate(val, "PolicySetDefinitionVersion", &l.PolicySetDefinitionVersion) + delete(rawMsg, key) + case "resourceLocation": + err = unpopulate(val, "ResourceLocation", &l.ResourceLocation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type NonComplianceMessage. func (n NonComplianceMessage) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1420,37 +1096,6 @@ func (r *ResourceSelector) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceTypeAliases. -func (r ResourceTypeAliases) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "aliases", r.Aliases) - populate(objectMap, "resourceType", r.ResourceType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceTypeAliases. -func (r *ResourceTypeAliases) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "aliases": - err = unpopulate(val, "Aliases", &r.Aliases) - delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &r.ResourceType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Selector. func (s Selector) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1751,10 +1396,10 @@ func (s *SetDefinitionVersionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateTime[datetime.RFC3339](objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateTime[datetime.RFC3339](objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -1770,7 +1415,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateTime[datetime.RFC3339](val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -1779,7 +1424,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateTime[datetime.RFC3339](val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) @@ -1795,292 +1440,153 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. -func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "clientId", u.ClientID) - populate(objectMap, "principalId", u.PrincipalID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. -func (u *UserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "clientId": - err = unpopulate(val, "ClientID", &u.ClientID) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &u.PrincipalID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Variable. -func (v Variable) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TokenOperation. +func (t TokenOperation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "type", v.Type) + populateAny(objectMap, "content", t.Content) + populate(objectMap, "httpMethod", t.HTTPMethod) + populate(objectMap, "uri", t.URI) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Variable. -func (v *Variable) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenOperation. +func (t *TokenOperation) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &v.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &v.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &v.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &v.SystemData) + case "content": + err = unpopulate(val, "Content", &t.Content) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &v.Type) + case "httpMethod": + err = unpopulate(val, "HTTPMethod", &t.HTTPMethod) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableColumn. -func (v VariableColumn) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "columnName", v.ColumnName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableColumn. -func (v *VariableColumn) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "columnName": - err = unpopulate(val, "ColumnName", &v.ColumnName) + case "uri": + err = unpopulate(val, "URI", &t.URI) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableListResult. -func (v VariableListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TokenRequest. +func (t TokenRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populate(objectMap, "changeReference", t.ChangeReference) + populate(objectMap, "operation", t.Operation) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableListResult. -func (v *VariableListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenRequest. +func (t *TokenRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &v.NextLink) + case "changeReference": + err = unpopulate(val, "ChangeReference", &t.ChangeReference) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &v.Value) + case "operation": + err = unpopulate(val, "Operation", &t.Operation) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableProperties. -func (v VariableProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TokenResponse. +func (t TokenResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "columns", v.Columns) + populate(objectMap, "changeReference", t.ChangeReference) + populateTime[datetime.RFC3339](objectMap, "expiration", t.Expiration) + populate(objectMap, "message", t.Message) + populate(objectMap, "result", t.Result) + populate(objectMap, "results", t.Results) + populateTime[datetime.RFC3339](objectMap, "retryAfter", t.RetryAfter) + populate(objectMap, "token", t.Token) + populate(objectMap, "tokenId", t.TokenID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableProperties. -func (v *VariableProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenResponse. +func (t *TokenResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "columns": - err = unpopulate(val, "Columns", &v.Columns) + case "changeReference": + err = unpopulate(val, "ChangeReference", &t.ChangeReference) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValue. -func (v VariableValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "type", v.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValue. -func (v *VariableValue) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &v.ID) + case "expiration": + err = unpopulateTime[datetime.RFC3339](val, "Expiration", &t.Expiration) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &v.Name) + case "message": + err = unpopulate(val, "Message", &t.Message) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &v.Properties) + case "result": + err = unpopulate(val, "Result", &t.Result) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &v.SystemData) + case "results": + err = unpopulate(val, "Results", &t.Results) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &v.Type) + case "retryAfter": + err = unpopulateTime[datetime.RFC3339](val, "RetryAfter", &t.RetryAfter) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValueColumnValue. -func (v VariableValueColumnValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "columnName", v.ColumnName) - populateAny(objectMap, "columnValue", v.ColumnValue) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueColumnValue. -func (v *VariableValueColumnValue) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "columnName": - err = unpopulate(val, "ColumnName", &v.ColumnName) + case "token": + err = unpopulate(val, "Token", &t.Token) delete(rawMsg, key) - case "columnValue": - err = unpopulate(val, "ColumnValue", &v.ColumnValue) + case "tokenId": + err = unpopulate(val, "TokenID", &t.TokenID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableValueListResult. -func (v VariableValueListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. +func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueListResult. -func (v *VariableValueListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. +func (u *UserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &v.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &v.Value) + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValueProperties. -func (v VariableValueProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "values", v.Values) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueProperties. -func (v *VariableValueProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "values": - err = unpopulate(val, "Values", &v.Values) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil @@ -2096,6 +1602,17 @@ func populate(m map[string]any, k string, v any) { } } +func populateTime[T dateTimeConstraints](m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + } else if !reflect.ValueOf(t).IsNil() { + newTime := T(*t) + m[k] = (*T)(&newTime) + } +} + func populateAny(m map[string]any, k string, v any) { if v == nil { return @@ -2115,3 +1632,20 @@ func unpopulate(data json.RawMessage, fn string, v any) error { } return nil } + +func unpopulateTime[T dateTimeConstraints](data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux T + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + newTime := time.Time(aux) + *t = &newTime + return nil +} + +type dateTimeConstraints interface { + datetime.PlainDate | datetime.PlainTime | datetime.RFC1123 | datetime.RFC3339 | datetime.Unix +} diff --git a/sdk/resourcemanager/resources/armpolicy/options.go b/sdk/resourcemanager/resources/armpolicy/options.go index 9b81fe61d4ba..e0939a680e29 100644 --- a/sdk/resourcemanager/resources/armpolicy/options.go +++ b/sdk/resourcemanager/resources/armpolicy/options.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -27,9 +26,7 @@ type AssignmentsClientDeleteOptions struct { // AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. type AssignmentsClientGetByIDOptions struct { - // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, - // EffectiveDefinitionVersion'. - Expand *string + // placeholder for future optional parameters } // AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. @@ -47,12 +44,11 @@ type AssignmentsClientListForManagementGroupOptions struct { 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}. + // 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. @@ -67,12 +63,11 @@ type AssignmentsClientListForResourceGroupOptions struct { 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}. + // 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. @@ -87,12 +82,11 @@ type AssignmentsClientListForResourceOptions struct { 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}. + // 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. @@ -106,12 +100,11 @@ type AssignmentsClientListOptions struct { 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}. + // 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. @@ -128,20 +121,6 @@ type AssignmentsClientUpdateOptions struct { // placeholder for future optional parameters } -// DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode -// method. -type DataPolicyManifestsClientGetByPolicyModeOptions struct { - // placeholder for future optional parameters -} - -// DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.NewListPager method. -type DataPolicyManifestsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: "namespace eq '{value}'". If $filter is not provided, - // no filtering is performed. If $filter=namespace eq '{value}' is provided, the - // returned list only includes all data policy manifests that have a namespace matching the provided value. - Filter *string -} - // DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup // method. type DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -260,12 +239,11 @@ type DefinitionsClientGetOptions struct { // DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager method. 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}. + // 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. @@ -276,12 +254,11 @@ type DefinitionsClientListBuiltInOptions struct { // method. 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}. + // 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. @@ -291,105 +268,17 @@ type DefinitionsClientListByManagementGroupOptions struct { // DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.NewListPager method. 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}. + // 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 } -// ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate method. -type ExemptionsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ExemptionsClientDeleteOptions contains the optional parameters for the ExemptionsClient.Delete method. -type ExemptionsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ExemptionsClientGetOptions contains the optional parameters for the ExemptionsClient.Get method. -type ExemptionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.NewListForManagementGroupPager -// method. -type ExemptionsClientListForManagementGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions 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 exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.NewListForResourceGroupPager -// method. -type ExemptionsClientListForResourceGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions 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 exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.NewListForResourcePager -// method. -type ExemptionsClientListForResourceOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions 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 exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.NewListPager method. -type ExemptionsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions 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 exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientUpdateOptions contains the optional parameters for the ExemptionsClient.Update method. -type ExemptionsClientUpdateOptions struct { - // placeholder for future optional parameters -} - // SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup // method. type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -540,12 +429,11 @@ type SetDefinitionsClientListBuiltInOptions struct { 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}. + // 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. @@ -560,12 +448,11 @@ type SetDefinitionsClientListByManagementGroupOptions struct { 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}. + // 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. @@ -579,103 +466,24 @@ type SetDefinitionsClientListOptions struct { 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}. + // 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 } -// VariableValuesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdateAtManagementGroup -// method. -type VariableValuesClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientCreateOrUpdateOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdate -// method. -type VariableValuesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.DeleteAtManagementGroup -// method. -type VariableValuesClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientDeleteOptions contains the optional parameters for the VariableValuesClient.Delete method. -type VariableValuesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientGetAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.GetAtManagementGroup -// method. -type VariableValuesClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientGetOptions contains the optional parameters for the VariableValuesClient.Get method. -type VariableValuesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientListForManagementGroupOptions contains the optional parameters for the VariableValuesClient.NewListForManagementGroupPager -// method. -type VariableValuesClientListForManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.NewListPager method. -type VariableValuesClientListOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariablesClient.CreateOrUpdateAtManagementGroup -// method. -type VariablesClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientCreateOrUpdateOptions contains the optional parameters for the VariablesClient.CreateOrUpdate method. -type VariablesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariablesClient.DeleteAtManagementGroup -// method. -type VariablesClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientDeleteOptions contains the optional parameters for the VariablesClient.Delete method. -type VariablesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientGetAtManagementGroupOptions contains the optional parameters for the VariablesClient.GetAtManagementGroup -// method. -type VariablesClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientGetOptions contains the optional parameters for the VariablesClient.Get method. -type VariablesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientListForManagementGroupOptions contains the optional parameters for the VariablesClient.NewListForManagementGroupPager +// TokensClientAcquireAtManagementGroupOptions contains the optional parameters for the TokensClient.AcquireAtManagementGroup // method. -type VariablesClientListForManagementGroupOptions struct { +type TokensClientAcquireAtManagementGroupOptions struct { // placeholder for future optional parameters } -// VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. -type VariablesClientListOptions struct { +// TokensClientAcquireOptions contains the optional parameters for the TokensClient.Acquire method. +type TokensClientAcquireOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/resources/armpolicy/responses.go b/sdk/resourcemanager/resources/armpolicy/responses.go index ec47e2fb4c16..1eebc55f2231 100644 --- a/sdk/resourcemanager/resources/armpolicy/responses.go +++ b/sdk/resourcemanager/resources/armpolicy/responses.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -43,25 +42,25 @@ type AssignmentsClientGetResponse struct { // AssignmentsClientListForManagementGroupResponse contains the response from method AssignmentsClient.NewListForManagementGroupPager. type AssignmentsClientListForManagementGroupResponse struct { - // List of policy assignments. + // The response of a PolicyAssignment list operation. AssignmentListResult } // AssignmentsClientListForResourceGroupResponse contains the response from method AssignmentsClient.NewListForResourceGroupPager. type AssignmentsClientListForResourceGroupResponse struct { - // List of policy assignments. + // The response of a PolicyAssignment list operation. AssignmentListResult } // AssignmentsClientListForResourceResponse contains the response from method AssignmentsClient.NewListForResourcePager. type AssignmentsClientListForResourceResponse struct { - // List of policy assignments. + // The response of a PolicyAssignment list operation. AssignmentListResult } // AssignmentsClientListResponse contains the response from method AssignmentsClient.NewListPager. type AssignmentsClientListResponse struct { - // List of policy assignments. + // The response of a PolicyAssignment list operation. AssignmentListResult } @@ -77,18 +76,6 @@ type AssignmentsClientUpdateResponse struct { Assignment } -// DataPolicyManifestsClientGetByPolicyModeResponse contains the response from method DataPolicyManifestsClient.GetByPolicyMode. -type DataPolicyManifestsClientGetByPolicyModeResponse struct { - // The data policy manifest. - DataPolicyManifest -} - -// DataPolicyManifestsClientListResponse contains the response from method DataPolicyManifestsClient.NewListPager. -type DataPolicyManifestsClientListResponse struct { - // List of data policy manifests. - DataPolicyManifestListResult -} - // DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionVersionsClient.CreateOrUpdateAtManagementGroup. type DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { // The ID of the policy definition version. @@ -131,37 +118,37 @@ type DefinitionVersionsClientGetResponse struct { // DefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method DefinitionVersionsClient.ListAllAtManagementGroup. type DefinitionVersionsClientListAllAtManagementGroupResponse struct { - // List of policy definition versions. + // The response of a PolicyDefinitionVersion list operation. DefinitionVersionListResult } // DefinitionVersionsClientListAllBuiltinsResponse contains the response from method DefinitionVersionsClient.ListAllBuiltins. type DefinitionVersionsClientListAllBuiltinsResponse struct { - // List of policy definition versions. + // The response of a PolicyDefinitionVersion list operation. DefinitionVersionListResult } // DefinitionVersionsClientListAllResponse contains the response from method DefinitionVersionsClient.ListAll. type DefinitionVersionsClientListAllResponse struct { - // List of policy definition versions. + // The response of a PolicyDefinitionVersion list operation. DefinitionVersionListResult } // DefinitionVersionsClientListBuiltInResponse contains the response from method DefinitionVersionsClient.NewListBuiltInPager. type DefinitionVersionsClientListBuiltInResponse struct { - // List of policy definition versions. + // The response of a PolicyDefinitionVersion list operation. DefinitionVersionListResult } // DefinitionVersionsClientListByManagementGroupResponse contains the response from method DefinitionVersionsClient.NewListByManagementGroupPager. type DefinitionVersionsClientListByManagementGroupResponse struct { - // List of policy definition versions. + // The response of a PolicyDefinitionVersion list operation. DefinitionVersionListResult } // DefinitionVersionsClientListResponse contains the response from method DefinitionVersionsClient.NewListPager. type DefinitionVersionsClientListResponse struct { - // List of policy definition versions. + // The response of a PolicyDefinitionVersion list operation. DefinitionVersionListResult } @@ -207,69 +194,22 @@ type DefinitionsClientGetResponse struct { // DefinitionsClientListBuiltInResponse contains the response from method DefinitionsClient.NewListBuiltInPager. type DefinitionsClientListBuiltInResponse struct { - // List of policy definitions. + // The response of a PolicyDefinition list operation. DefinitionListResult } // DefinitionsClientListByManagementGroupResponse contains the response from method DefinitionsClient.NewListByManagementGroupPager. type DefinitionsClientListByManagementGroupResponse struct { - // List of policy definitions. + // The response of a PolicyDefinition list operation. DefinitionListResult } // DefinitionsClientListResponse contains the response from method DefinitionsClient.NewListPager. type DefinitionsClientListResponse struct { - // List of policy definitions. + // The response of a PolicyDefinition list operation. DefinitionListResult } -// ExemptionsClientCreateOrUpdateResponse contains the response from method ExemptionsClient.CreateOrUpdate. -type ExemptionsClientCreateOrUpdateResponse struct { - // The policy exemption. - Exemption -} - -// ExemptionsClientDeleteResponse contains the response from method ExemptionsClient.Delete. -type ExemptionsClientDeleteResponse struct { - // placeholder for future response values -} - -// ExemptionsClientGetResponse contains the response from method ExemptionsClient.Get. -type ExemptionsClientGetResponse struct { - // The policy exemption. - Exemption -} - -// ExemptionsClientListForManagementGroupResponse contains the response from method ExemptionsClient.NewListForManagementGroupPager. -type ExemptionsClientListForManagementGroupResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientListForResourceGroupResponse contains the response from method ExemptionsClient.NewListForResourceGroupPager. -type ExemptionsClientListForResourceGroupResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientListForResourceResponse contains the response from method ExemptionsClient.NewListForResourcePager. -type ExemptionsClientListForResourceResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientListResponse contains the response from method ExemptionsClient.NewListPager. -type ExemptionsClientListResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientUpdateResponse contains the response from method ExemptionsClient.Update. -type ExemptionsClientUpdateResponse struct { - // The policy exemption. - Exemption -} - // SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup. type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { // The policy set definition version. @@ -312,37 +252,37 @@ type SetDefinitionVersionsClientGetResponse struct { // SetDefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.ListAllAtManagementGroup. type SetDefinitionVersionsClientListAllAtManagementGroupResponse struct { - // List of policy set definition versions. + // The response of a PolicySetDefinitionVersion list operation. SetDefinitionVersionListResult } // SetDefinitionVersionsClientListAllBuiltinsResponse contains the response from method SetDefinitionVersionsClient.ListAllBuiltins. type SetDefinitionVersionsClientListAllBuiltinsResponse struct { - // List of policy set definition versions. + // The response of a PolicySetDefinitionVersion list operation. SetDefinitionVersionListResult } // SetDefinitionVersionsClientListAllResponse contains the response from method SetDefinitionVersionsClient.ListAll. type SetDefinitionVersionsClientListAllResponse struct { - // List of policy set definition versions. + // The response of a PolicySetDefinitionVersion list operation. SetDefinitionVersionListResult } // SetDefinitionVersionsClientListBuiltInResponse contains the response from method SetDefinitionVersionsClient.NewListBuiltInPager. type SetDefinitionVersionsClientListBuiltInResponse struct { - // List of policy set definition versions. + // The response of a PolicySetDefinitionVersion list operation. SetDefinitionVersionListResult } // SetDefinitionVersionsClientListByManagementGroupResponse contains the response from method SetDefinitionVersionsClient.NewListByManagementGroupPager. type SetDefinitionVersionsClientListByManagementGroupResponse struct { - // List of policy set definition versions. + // The response of a PolicySetDefinitionVersion list operation. SetDefinitionVersionListResult } // SetDefinitionVersionsClientListResponse contains the response from method SetDefinitionVersionsClient.NewListPager. type SetDefinitionVersionsClientListResponse struct { - // List of policy set definition versions. + // The response of a PolicySetDefinitionVersion list operation. SetDefinitionVersionListResult } @@ -388,110 +328,30 @@ type SetDefinitionsClientGetResponse struct { // SetDefinitionsClientListBuiltInResponse contains the response from method SetDefinitionsClient.NewListBuiltInPager. type SetDefinitionsClientListBuiltInResponse struct { - // List of policy set definitions. + // The response of a PolicySetDefinition list operation. SetDefinitionListResult } // SetDefinitionsClientListByManagementGroupResponse contains the response from method SetDefinitionsClient.NewListByManagementGroupPager. type SetDefinitionsClientListByManagementGroupResponse struct { - // List of policy set definitions. + // The response of a PolicySetDefinition list operation. SetDefinitionListResult } // SetDefinitionsClientListResponse contains the response from method SetDefinitionsClient.NewListPager. type SetDefinitionsClientListResponse struct { - // List of policy set definitions. + // The response of a PolicySetDefinition list operation. SetDefinitionListResult } -// VariableValuesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariableValuesClient.CreateOrUpdateAtManagementGroup. -type VariableValuesClientCreateOrUpdateAtManagementGroupResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientCreateOrUpdateResponse contains the response from method VariableValuesClient.CreateOrUpdate. -type VariableValuesClientCreateOrUpdateResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientDeleteAtManagementGroupResponse contains the response from method VariableValuesClient.DeleteAtManagementGroup. -type VariableValuesClientDeleteAtManagementGroupResponse struct { - // placeholder for future response values -} - -// VariableValuesClientDeleteResponse contains the response from method VariableValuesClient.Delete. -type VariableValuesClientDeleteResponse struct { - // placeholder for future response values -} - -// VariableValuesClientGetAtManagementGroupResponse contains the response from method VariableValuesClient.GetAtManagementGroup. -type VariableValuesClientGetAtManagementGroupResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientGetResponse contains the response from method VariableValuesClient.Get. -type VariableValuesClientGetResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientListForManagementGroupResponse contains the response from method VariableValuesClient.NewListForManagementGroupPager. -type VariableValuesClientListForManagementGroupResponse struct { - // List of variable values. - VariableValueListResult -} - -// VariableValuesClientListResponse contains the response from method VariableValuesClient.NewListPager. -type VariableValuesClientListResponse struct { - // List of variable values. - VariableValueListResult -} - -// VariablesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariablesClient.CreateOrUpdateAtManagementGroup. -type VariablesClientCreateOrUpdateAtManagementGroupResponse struct { - // The variable. - Variable -} - -// VariablesClientCreateOrUpdateResponse contains the response from method VariablesClient.CreateOrUpdate. -type VariablesClientCreateOrUpdateResponse struct { - // The variable. - Variable -} - -// VariablesClientDeleteAtManagementGroupResponse contains the response from method VariablesClient.DeleteAtManagementGroup. -type VariablesClientDeleteAtManagementGroupResponse struct { - // placeholder for future response values -} - -// VariablesClientDeleteResponse contains the response from method VariablesClient.Delete. -type VariablesClientDeleteResponse struct { - // placeholder for future response values -} - -// VariablesClientGetAtManagementGroupResponse contains the response from method VariablesClient.GetAtManagementGroup. -type VariablesClientGetAtManagementGroupResponse struct { - // The variable. - Variable -} - -// VariablesClientGetResponse contains the response from method VariablesClient.Get. -type VariablesClientGetResponse struct { - // The variable. - Variable -} - -// VariablesClientListForManagementGroupResponse contains the response from method VariablesClient.NewListForManagementGroupPager. -type VariablesClientListForManagementGroupResponse struct { - // List of variables. - VariableListResult +// TokensClientAcquireAtManagementGroupResponse contains the response from method TokensClient.AcquireAtManagementGroup. +type TokensClientAcquireAtManagementGroupResponse struct { + // The policy token response properties. + TokenResponse } -// VariablesClientListResponse contains the response from method VariablesClient.NewListPager. -type VariablesClientListResponse struct { - // List of variables. - VariableListResult +// TokensClientAcquireResponse contains the response from method TokensClient.Acquire. +type TokensClientAcquireResponse struct { + // The policy token response properties. + TokenResponse } diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go index 93b87e2da6d0..2ce15fa4b344 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -18,7 +17,7 @@ import ( "strings" ) -// SetDefinitionsClient contains the methods for the PolicySetDefinitions group. +// SetDefinitionsClient contains the methods for the SetDefinitions group. // Don't use this type directly, use NewSetDefinitionsClient() instead. type SetDefinitionsClient struct { internal *arm.Client @@ -28,7 +27,7 @@ type SetDefinitionsClient struct { // 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 - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -44,8 +43,8 @@ func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCrede // 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 2023-04-01 -// - policySetDefinitionName - The name of the policy set definition to create. +// 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. @@ -87,9 +86,10 @@ func (client *SetDefinitionsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -109,9 +109,9 @@ func (client *SetDefinitionsClient) createOrUpdateHandleResponse(resp *http.Resp // with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. -// - policySetDefinitionName - The name of the policy set definition to create. +// - 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. @@ -153,9 +153,10 @@ func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -174,8 +175,8 @@ func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupHandleRespons // 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 2023-04-01 -// - policySetDefinitionName - The name of the policy set definition to delete. +// 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. func (client *SetDefinitionsClient) Delete(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientDeleteOptions) (SetDefinitionsClientDeleteResponse, error) { var err error @@ -214,9 +215,8 @@ func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, pol return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -224,9 +224,9 @@ func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, pol // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. -// - policySetDefinitionName - The name of the policy set definition to delete. +// - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup // method. func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (SetDefinitionsClientDeleteAtManagementGroupResponse, error) { @@ -266,16 +266,15 @@ func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2023-04-01 +// 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. func (client *SetDefinitionsClient) Get(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientGetOptions) (SetDefinitionsClientGetResponse, error) { @@ -319,7 +318,7 @@ func (client *SetDefinitionsClient) getCreateRequest(ctx context.Context, policy if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,7 +337,7 @@ func (client *SetDefinitionsClient) getHandleResponse(resp *http.Response) (SetD // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -384,7 +383,7 @@ func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx contex if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -402,7 +401,7 @@ func (client *SetDefinitionsClient) getAtManagementGroupHandleResponse(resp *htt // 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 2023-04-01 +// 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. @@ -443,7 +442,7 @@ func (client *SetDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -459,17 +458,15 @@ func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response } // 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}. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method. func (client *SetDefinitionsClient) NewListPager(options *SetDefinitionsClientListOptions) *runtime.Pager[SetDefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SetDefinitionsClientListResponse]{ @@ -509,16 +506,14 @@ func (client *SetDefinitionsClient) listCreateRequest(ctx context.Context, optio if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -533,10 +528,10 @@ func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (Set } // 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}. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager // method. func (client *SetDefinitionsClient) NewListBuiltInPager(options *SetDefinitionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionsClientListBuiltInResponse] { @@ -573,16 +568,14 @@ func (client *SetDefinitionsClient) listBuiltInCreateRequest(ctx context.Context if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -597,17 +590,15 @@ func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Respons } // 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}. +// 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 2023-04-01 +// 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. @@ -649,16 +640,14 @@ func (client *SetDefinitionsClient) listByManagementGroupCreateRequest(ctx conte if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go index dfb169df44ab..fff3d43d5bda 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinition.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinition.json func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefinition() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -66,7 +63,8 @@ func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefiniti }, PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, + }, + }, }, }, nil) if err != nil { @@ -75,62 +73,65 @@ func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefiniti // 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.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"), - // }, + // 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", // }, - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, + // 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"), // }, // }, - // 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')]", + // PolicyDefinitions: []*armpolicy.DefinitionReference{ + // { + // Parameters: map[string]*armpolicy.ParameterValuesValue{ + // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ + // Value: []any{ + // "Standard_GRS", + // "Standard_LRS", + // }, + // }, // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, + // }, + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroups.json func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefinitionWithGroups() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -151,12 +152,14 @@ func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefiniti 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")}, + to.Ptr("CostSaving"), + }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "listOfAllowedSKUs": { Value: []any{ @@ -171,7 +174,8 @@ func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefiniti { DefinitionVersion: to.Ptr("1.*.*"), GroupNames: []*string{ - to.Ptr("Organizational")}, + to.Ptr("Organizational"), + }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "prefix": { Value: "DeptA", @@ -182,7 +186,8 @@ func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefiniti }, PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, + }, + }, }, }, nil) if err != nil { @@ -191,127 +196,35 @@ func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefiniti // 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.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"), + // 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", // }, - // { - // 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"), + // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ + // { + // Name: to.Ptr("CostSaving"), + // Description: to.Ptr("Policies designed to control spend within a subscription."), + // DisplayName: to.Ptr("Cost Management Policies"), // }, // { - // 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")}, + // Name: to.Ptr("Organizational"), + // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), + // DisplayName: to.Ptr("Organizational Policies"), // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinition.json -func ExampleSetDefinitionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionsClient().Delete(ctx, "CostManagement", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinition.json -func ExampleSetDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().Get(ctx, "CostManagement", &armpolicy.SetDefinitionsClientGetOptions{Expand: 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.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")}, + // PolicyDefinitions: []*armpolicy.DefinitionReference{ + // { + // DefinitionVersion: to.Ptr("1.*.*"), + // GroupNames: []*string{ + // to.Ptr("CostSaving"), + // }, // Parameters: map[string]*armpolicy.ParameterValuesValue{ // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ // Value: []any{ @@ -326,369 +239,38 @@ func ExampleSetDefinitionsClient_Get() { // { // DefinitionVersion: to.Ptr("1.*.*"), // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, + // 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")}, + // }, + // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), + // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltInPolicySetDefinition.json -func ExampleSetDefinitionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().GetBuiltIn(ctx, "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", &armpolicy.SetDefinitionsClientGetBuiltInOptions{Expand: 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.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"), + // Version: to.Ptr("1.2.1"), + // Versions: []*string{ + // to.Ptr("1.2.1"), + // to.Ptr("1.0.0"), // }, - // { - // 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")}, // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitions.json -func ExampleSetDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListPager(&armpolicy.SetDefinitionsClientListOptions{Filter: nil, - Expand: nil, - Top: 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.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")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicySetDefinitions.json -func ExampleSetDefinitionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListBuiltInPager(&armpolicy.SetDefinitionsClientListBuiltInOptions{Filter: nil, - Expand: nil, - Top: 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.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")}, - // }, - // }}, - // } - } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -723,7 +305,8 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA }, PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, + }, + }, }, }, nil) if err != nil { @@ -732,55 +315,58 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA // 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.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", + // 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"), // }, - // 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", + // { + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, + // }, + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json +// Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -801,11 +387,13 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA 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")}, + to.Ptr("CostSaving"), + }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "listOfAllowedSKUs": { Value: []any{ @@ -819,7 +407,8 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA }, { GroupNames: []*string{ - to.Ptr("Organizational")}, + to.Ptr("Organizational"), + }, Parameters: map[string]*armpolicy.ParameterValuesValue{ "prefix": { Value: "DeptA", @@ -830,7 +419,8 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA }, PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, + }, + }, }, }, nil) if err != nil { @@ -839,32 +429,35 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA // 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.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"), + // 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"), + // }, // }, - // { - // 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")}, + // PolicyDefinitions: []*armpolicy.DefinitionReference{ + // { + // DefinitionVersion: to.Ptr("1.*.*"), + // GroupNames: []*string{ + // to.Ptr("CostSaving"), + // }, // Parameters: map[string]*armpolicy.ParameterValuesValue{ // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ // Value: []any{ @@ -879,121 +472,332 @@ func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateA // { // DefinitionVersion: to.Ptr("1.*.*"), // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, + // 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")}, + // }, + // 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"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/deletePolicySetDefinition.json +func ExampleSetDefinitionsClient_Delete() { + 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{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinitionAtManagementGroup.json +// Generated from example definition: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json func ExampleSetDefinitionsClient_DeleteAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewSetDefinitionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", nil) + 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{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_GetAtManagementGroup() { +// Generated from example definition: 2025-03-01/getPolicySetDefinition.json +func ExampleSetDefinitionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().GetAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", &armpolicy.SetDefinitionsClientGetAtManagementGroupOptions{Expand: nil}) + 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.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", + // 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"), // }, - // 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", + // Version: to.Ptr("1.2.1"), + // Versions: []*string{ + // to.Ptr("1.2.1"), + // to.Ptr("1.0.0"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json +func ExampleSetDefinitionsClient_GetAtManagementGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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", + // }, + // }, // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // 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")}, + // }, + // Version: to.Ptr("1.2.1"), + // Versions: []*string{ + // to.Ptr("1.2.1"), + // to.Ptr("1.0.0"), + // }, // }, - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitionsByManagementGroup.json -func ExampleSetDefinitionsClient_NewListByManagementGroupPager() { +// Generated from example definition: 2025-03-01/getBuiltInPolicySetDefinition.json +func ExampleSetDefinitionsClient_GetBuiltIn() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSetDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: nil, - Expand: nil, - Top: nil, - }) + 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"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/listPolicySetDefinitions.json +func ExampleSetDefinitionsClient_NewListPager() { + 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 { @@ -1004,74 +808,328 @@ func ExampleSetDefinitionsClient_NewListByManagementGroupPager() { _ = 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.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{ + // 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"), + // }, // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), + // }, + // { + // 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", // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), + // 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"), + // }, // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), + // Version: to.Ptr("1.2.1"), + // Versions: []*string{ + // to.Ptr("1.2.1"), + // to.Ptr("1.0.0"), // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/listBuiltInPolicySetDefinitions.json +func ExampleSetDefinitionsClient_NewListBuiltInPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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", // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), + // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), + // 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"), + // }, // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), + // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), + // Version: to.Ptr("1.2.1"), + // Versions: []*string{ + // to.Ptr("1.2.1"), + // to.Ptr("1.0.0"), // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json +func ExampleSetDefinitionsClient_NewListByManagementGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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", // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), + // 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"), // }, - // { - // 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")}, // }, // }, // { @@ -1110,13 +1168,17 @@ func ExampleSetDefinitionsClient_NewListByManagementGroupPager() { // }, // 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")}, + // to.Ptr("1.0.0"), // }, - // }}, - // } + // }, + // }, + // }, + // }, + // } } } diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go index 9d44a9dac965..e0a07fa01616 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy @@ -18,7 +17,7 @@ import ( "strings" ) -// SetDefinitionVersionsClient contains the methods for the PolicySetDefinitionVersions group. +// SetDefinitionVersionsClient contains the methods for the SetDefinitionVersions group. // Don't use this type directly, use NewSetDefinitionVersionsClient() instead. type SetDefinitionVersionsClient struct { internal *arm.Client @@ -28,7 +27,7 @@ type SetDefinitionVersionsClient struct { // 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 - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewSetDefinitionVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionVersionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -45,7 +44,7 @@ func NewSetDefinitionVersionsClient(subscriptionID string, credential azcore.Tok // name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -94,9 +93,10 @@ func (client *SetDefinitionVersionsClient) createOrUpdateCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -116,7 +116,7 @@ func (client *SetDefinitionVersionsClient) createOrUpdateHandleResponse(resp *ht // group with the given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -166,9 +166,10 @@ func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupCreate return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -187,7 +188,7 @@ func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupHandle // 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 2023-04-01 +// 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 @@ -234,9 +235,8 @@ func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -244,7 +244,7 @@ func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Conte // given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -292,16 +292,15 @@ func (client *SetDefinitionVersionsClient) deleteAtManagementGroupCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2023-04-01 +// 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 @@ -352,7 +351,7 @@ func (client *SetDefinitionVersionsClient) getCreateRequest(ctx context.Context, if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +370,7 @@ func (client *SetDefinitionVersionsClient) getHandleResponse(resp *http.Response // given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// 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 @@ -423,7 +422,7 @@ func (client *SetDefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -441,7 +440,7 @@ func (client *SetDefinitionVersionsClient) getAtManagementGroupHandleResponse(re // 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 2023-04-01 +// 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 @@ -488,7 +487,7 @@ func (client *SetDefinitionVersionsClient) getBuiltInCreateRequest(ctx context.C if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -505,7 +504,7 @@ func (client *SetDefinitionVersionsClient) getBuiltInHandleResponse(resp *http.R // NewListPager - This operation retrieves a list of all the policy set definition versions for the given policy set definition. // -// Generated from API version 2023-04-01 +// 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. @@ -554,7 +553,7 @@ func (client *SetDefinitionVersionsClient) listCreateRequest(ctx context.Context if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -569,10 +568,12 @@ func (client *SetDefinitionVersionsClient) listHandleResponse(resp *http.Respons return result, nil } -// ListAll - This operation lists all the policy set definition versions for all policy set definitions within a subscription. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll // method. func (client *SetDefinitionVersionsClient) ListAll(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error) { @@ -609,7 +610,7 @@ func (client *SetDefinitionVersionsClient) listAllCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -624,11 +625,12 @@ func (client *SetDefinitionVersionsClient) listAllHandleResponse(resp *http.Resp return result, nil } -// ListAllAtManagementGroup - This operation lists all the policy set definition versions for all policy set definitions at -// the management group scope. +// 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 2023-04-01 +// 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. @@ -666,7 +668,7 @@ func (client *SetDefinitionVersionsClient) listAllAtManagementGroupCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -681,10 +683,12 @@ func (client *SetDefinitionVersionsClient) listAllAtManagementGroupHandleRespons return result, nil } -// ListAllBuiltins - This operation lists all the built-in policy set definition versions for all built-in policy set definitions. +// 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 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins // method. func (client *SetDefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) { @@ -717,7 +721,7 @@ func (client *SetDefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -735,7 +739,7 @@ func (client *SetDefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *h // 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 2023-04-01 +// 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. @@ -780,7 +784,7 @@ func (client *SetDefinitionVersionsClient) listBuiltInCreateRequest(ctx context. if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -798,7 +802,7 @@ func (client *SetDefinitionVersionsClient) listBuiltInHandleResponse(resp *http. // 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 2023-04-01 +// 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 @@ -848,7 +852,7 @@ func (client *SetDefinitionVersionsClient) listByManagementGroupCreateRequest(ct if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go index 13c196ef8f31..3407b03dfe9c 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go @@ -1,330 +1,151 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armpolicy_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllBuiltInPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_ListAllBuiltins() { +// Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json +func ExampleSetDefinitionVersionsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().ListAllBuiltins(ctx, nil) + 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.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"), + // 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", // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json -func ExampleSetDefinitionVersionsClient_ListAllAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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.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"), + // 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"), // }, - // { - // 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", - // }, + // }, + // 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"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_ListAll() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", 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.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", + // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), + // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, + // { + // DefinitionVersion: to.Ptr("1.*.*"), + // Parameters: map[string]*armpolicy.ParameterValuesValue{ + // "prefix": &armpolicy.ParameterValuesValue{ + // Value: "[parameters('namePrefix')]", // }, - // 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", - // }, + // "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"), + // }, + // 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"), + // }, + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionVersion.json -func ExampleSetDefinitionVersionsClient_CreateOrUpdate() { +// Generated from example definition: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json +func ExampleSetDefinitionVersionsClient_CreateOrUpdateAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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{ + 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", }, - 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{ @@ -335,21 +156,22 @@ func ExampleSetDefinitionVersionsClient_CreateOrUpdate() { }, }, }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), + 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: "[parameters('namePrefix')]", + Value: "DeptA", }, "suffix": { Value: "-LC", }, }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), + 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) @@ -359,118 +181,141 @@ func ExampleSetDefinitionVersionsClient_CreateOrUpdate() { // 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.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"), - // }, + // 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", + // 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"), // }, - // 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", + // { + // 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"), // }, - // 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"), + // }, + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinitionVersion.json +// Generated from example definition: 2025-03-01/deletePolicySetDefinitionVersion.json func ExampleSetDefinitionVersionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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{ + // } +} + +// Generated from example definition: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json +func ExampleSetDefinitionVersionsClient_DeleteAtManagementGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewSetDefinitionVersionsClient().Delete(ctx, "CostManagement", "1.2.1", nil) + 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{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinitionVersion.json +// Generated from example definition: 2025-03-01/getPolicySetDefinitionVersion.json func ExampleSetDefinitionVersionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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", &armpolicy.SetDefinitionVersionsClientGetOptions{Expand: nil}) + 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.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"), + // 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", // }, - // { - // 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")}, + // 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{ @@ -485,194 +330,191 @@ func ExampleSetDefinitionVersionsClient_Get() { // { // DefinitionVersion: to.Ptr("1.*.*"), // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, + // 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"), + // }, + // 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"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltInPolicySetDefinitionVersion.json -func ExampleSetDefinitionVersionsClient_GetBuiltIn() { +// Generated from example definition: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json +func ExampleSetDefinitionVersionsClient_GetAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", 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", &armpolicy.SetDefinitionVersionsClientGetBuiltInOptions{Expand: nil}) + 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.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"), + // 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", // }, - // { - // 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"), + // 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"), + // }, // }, - // { - // 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"), + // Version: to.Ptr("1.2.1"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_NewListPager() { +// Generated from example definition: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json +func ExampleSetDefinitionVersionsClient_GetBuiltIn() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSetDefinitionVersionsClient().NewListPager("CostManagement", &armpolicy.SetDefinitionVersionsClientListOptions{Expand: nil, - Top: 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.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"), - // }, - // }}, - // } + 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"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_NewListBuiltInPager() { +// Generated from example definition: 2025-03-01/listPolicySetDefinitionVersions.json +func ExampleSetDefinitionVersionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().NewListBuiltInPager("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", &armpolicy.SetDefinitionVersionsClientListBuiltInOptions{Expand: nil, - Top: nil, - }) + pager := clientFactory.NewSetDefinitionVersionsClient().NewListPager("CostManagement", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -683,263 +525,364 @@ func ExampleSetDefinitionVersionsClient_NewListBuiltInPager() { _ = 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.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"), + // 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", // }, - // { - // 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"), + // 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"), + // }, // }, - // { - // 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"), + // Version: to.Ptr("1.2.1"), + // }, // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json -func ExampleSetDefinitionVersionsClient_CreateOrUpdateAtManagementGroup() { +// Generated from example definition: 2025-03-01/listAllPolicySetDefinitionVersions.json +func ExampleSetDefinitionVersionsClient_ListAll() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + 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().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) + 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.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{ + // res = armpolicy.SetDefinitionVersionsClientListAllResponse{ + // SetDefinitionVersionListResult: &armpolicy.SetDefinitionVersionListResult{ + // Value: []*armpolicy.SetDefinitionVersion{ // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", + // 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"), // }, - // 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"), - // }}, + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json -func ExampleSetDefinitionVersionsClient_DeleteAtManagementGroup() { +// Generated from example definition: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json +func ExampleSetDefinitionVersionsClient_ListAllAtManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewSetDefinitionVersionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", nil) + 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"), + // }, + // }, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json -func ExampleSetDefinitionVersionsClient_GetAtManagementGroup() { +// Generated from example definition: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json +func ExampleSetDefinitionVersionsClient_ListAllBuiltins() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewSetDefinitionVersionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", &armpolicy.SetDefinitionVersionsClientGetAtManagementGroupOptions{Expand: nil}) + 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.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{ + // res = armpolicy.SetDefinitionVersionsClientListAllBuiltinsResponse{ + // SetDefinitionVersionListResult: &armpolicy.SetDefinitionVersionListResult{ + // Value: []*armpolicy.SetDefinitionVersion{ // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, + // 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", // }, - // }, - // 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", + // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), + // }, + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json -func ExampleSetDefinitionVersionsClient_NewListByManagementGroupPager() { +// Generated from example definition: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json +func ExampleSetDefinitionVersionsClient_NewListBuiltInPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) + clientFactory, err := armpolicy.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewSetDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "CostManagement", &armpolicy.SetDefinitionVersionsClientListByManagementGroupOptions{Expand: nil, - Top: nil, - }) + pager := clientFactory.NewSetDefinitionVersionsClient().NewListBuiltInPager("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -950,48 +893,151 @@ func ExampleSetDefinitionVersionsClient_NewListByManagementGroupPager() { _ = 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.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", + // 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"), // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json +func ExampleSetDefinitionVersionsClient_NewListByManagementGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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"), // }, - // 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", + // { + // 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"), // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), + // }, + // Version: to.Ptr("1.2.1"), + // }, // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/resources/armpolicy/testdata/_metadata.json b/sdk/resourcemanager/resources/armpolicy/testdata/_metadata.json new file mode 100644 index 000000000000..477cc69777a6 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2025-03-01", + "emitterVersion": "0.9.2" +} diff --git a/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go deleted file mode 100644 index 3d0a000e3368..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) - -const ( - utcDateTime = "2006-01-02T15:04:05.999999999" - utcDateTimeJSON = `"` + utcDateTime + `"` - utcDateTimeNoT = "2006-01-02 15:04:05.999999999" - utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` - dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` - dateTimeJSON = `"` + time.RFC3339Nano + `"` - dateTimeJSONNoT = `"` + dateTimeNoT + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = dateTimeJSON - } else if tzOffset { - layout = dateTimeJSONNoT - } else if hasT { - layout = utcDateTimeJSON - } else { - layout = utcDateTimeJSONNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - if len(data) == 0 { - return nil - } - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = time.RFC3339Nano - } else if tzOffset { - layout = dateTimeNoT - } else if hasT { - layout = utcDateTime - } else { - layout = utcDateTimeNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func (t dateTimeRFC3339) String() string { - return time.Time(t).Format(time.RFC3339Nano) -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || string(data) == "null" { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/tokens_client.go b/sdk/resourcemanager/resources/armpolicy/tokens_client.go new file mode 100644 index 000000000000..e02db5dc12d3 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/tokens_client.go @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armpolicy + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TokensClient contains the methods for the Tokens group. +// Don't use this type directly, use NewTokensClient() instead. +type TokensClient struct { + internal *arm.Client + subscriptionID string +} + +// 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 NewTokensClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TokensClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TokensClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// 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. +func (client *TokensClient) Acquire(ctx context.Context, parameters TokenRequest, options *TokensClientAcquireOptions) (TokensClientAcquireResponse, error) { + var err error + const operationName = "TokensClient.Acquire" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.acquireCreateRequest(ctx, parameters, options) + if err != nil { + return TokensClientAcquireResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TokensClientAcquireResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TokensClientAcquireResponse{}, err + } + resp, err := client.acquireHandleResponse(httpResp) + return resp, err +} + +// acquireCreateRequest creates the Acquire request. +func (client *TokensClient) acquireCreateRequest(ctx context.Context, parameters TokenRequest, _ *TokensClientAcquireOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/acquirePolicyToken" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// acquireHandleResponse handles the Acquire response. +func (client *TokensClient) acquireHandleResponse(resp *http.Response) (TokensClientAcquireResponse, error) { + result := TokensClientAcquireResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TokenResponse); err != nil { + return TokensClientAcquireResponse{}, err + } + return result, nil +} + +// 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. +func (client *TokensClient) AcquireAtManagementGroup(ctx context.Context, managementGroupName string, parameters TokenRequest, options *TokensClientAcquireAtManagementGroupOptions) (TokensClientAcquireAtManagementGroupResponse, error) { + var err error + const operationName = "TokensClient.AcquireAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.acquireAtManagementGroupCreateRequest(ctx, managementGroupName, parameters, options) + if err != nil { + return TokensClientAcquireAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TokensClientAcquireAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TokensClientAcquireAtManagementGroupResponse{}, err + } + resp, err := client.acquireAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// acquireAtManagementGroupCreateRequest creates the AcquireAtManagementGroup request. +func (client *TokensClient) acquireAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, parameters TokenRequest, _ *TokensClientAcquireAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/acquirePolicyToken" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// acquireAtManagementGroupHandleResponse handles the AcquireAtManagementGroup response. +func (client *TokensClient) acquireAtManagementGroupHandleResponse(resp *http.Response) (TokensClientAcquireAtManagementGroupResponse, error) { + result := TokensClientAcquireAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TokenResponse); err != nil { + return TokensClientAcquireAtManagementGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/tokens_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/tokens_client_example_test.go new file mode 100644 index 000000000000..e9aeb2a241dd --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/tokens_client_example_test.go @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armpolicy_test + +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" +) + +// Generated from example definition: 2025-03-01/acquirePolicyToken.json +func ExampleTokensClient_Acquire() { + 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"), + // }, + // } +} + +// Generated from example definition: 2025-03-01/acquirePolicyTokenAtManagementGroup.json +func ExampleTokensClient_AcquireAtManagementGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpolicy.NewClientFactory("", 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"), + // }, + // } +} diff --git a/sdk/resourcemanager/resources/armpolicy/tsp-location.yaml b/sdk/resourcemanager/resources/armpolicy/tsp-location.yaml new file mode 100644 index 000000000000..da968927a16c --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/resources/resource-manager/Microsoft.Authorization/policy +commit: cf91e585edd2963d6a4ff52a70627b665d7d1e01 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client.go b/sdk/resourcemanager/resources/armpolicy/variables_client.go deleted file mode 100644 index 30ac3a1dd3af..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variables_client.go +++ /dev/null @@ -1,507 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// VariablesClient contains the methods for the Variables group. -// Don't use this type directly, use NewVariablesClient() instead. -type VariablesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVariablesClient creates a new instance of VariablesClient 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 - pass nil to accept the default values. -func NewVariablesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VariablesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VariablesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a variable with the given subscription and name. Policy variables can -// only be used by a policy definition at the scope they are created or below. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - parameters - Parameters for the variable. -// - options - VariablesClientCreateOrUpdateOptions contains the optional parameters for the VariablesClient.CreateOrUpdate -// method. -func (client *VariablesClient) CreateOrUpdate(ctx context.Context, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateOptions) (VariablesClientCreateOrUpdateResponse, error) { - var err error - const operationName = "VariablesClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, variableName, parameters, options) - if err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariablesClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VariablesClient) createOrUpdateCreateRequest(ctx context.Context, variableName string, parameters Variable, _ *VariablesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *VariablesClient) createOrUpdateHandleResponse(resp *http.Response) (VariablesClientCreateOrUpdateResponse, error) { - result := VariablesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// CreateOrUpdateAtManagementGroup - This operation creates or updates a variable with the given management group and name. -// Policy variables can only be used by a policy definition at the scope they are created or below. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - parameters - Parameters for the variable. -// - options - VariablesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariablesClient.CreateOrUpdateAtManagementGroup -// method. -func (client *VariablesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateAtManagementGroupOptions) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.CreateOrUpdateAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, parameters, options) - if err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *VariablesClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, parameters Variable, _ *VariablesClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. -func (client *VariablesClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error) { - result := VariablesClientCreateOrUpdateAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a variable, given its name and the subscription it was created in. The scope of a variable -// is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariablesClientDeleteOptions contains the optional parameters for the VariablesClient.Delete method. -func (client *VariablesClient) Delete(ctx context.Context, variableName string, options *VariablesClientDeleteOptions) (VariablesClientDeleteResponse, error) { - var err error - const operationName = "VariablesClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, variableName, options) - if err != nil { - return VariablesClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariablesClientDeleteResponse{}, err - } - return VariablesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VariablesClient) deleteCreateRequest(ctx context.Context, variableName string, _ *VariablesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// DeleteAtManagementGroup - This operation deletes a variable, given its name and the management group it was created in. -// The scope of a variable is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariablesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariablesClient.DeleteAtManagementGroup -// method. -func (client *VariablesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientDeleteAtManagementGroupOptions) (VariablesClientDeleteAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.DeleteAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - if err != nil { - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - return VariablesClientDeleteAtManagementGroupResponse{}, nil -} - -// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *VariablesClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, _ *VariablesClientDeleteAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single variable, given its name and the subscription it was created at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariablesClientGetOptions contains the optional parameters for the VariablesClient.Get method. -func (client *VariablesClient) Get(ctx context.Context, variableName string, options *VariablesClientGetOptions) (VariablesClientGetResponse, error) { - var err error - const operationName = "VariablesClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, variableName, options) - if err != nil { - return VariablesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariablesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VariablesClient) getCreateRequest(ctx context.Context, variableName string, _ *VariablesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VariablesClient) getHandleResponse(resp *http.Response) (VariablesClientGetResponse, error) { - result := VariablesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientGetResponse{}, err - } - return result, nil -} - -// GetAtManagementGroup - This operation retrieves a single variable, given its name and the management group it was created -// at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariablesClientGetAtManagementGroupOptions contains the optional parameters for the VariablesClient.GetAtManagementGroup -// method. -func (client *VariablesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientGetAtManagementGroupOptions) (VariablesClientGetAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.GetAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - if err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariablesClientGetAtManagementGroupResponse{}, err - } - resp, err := client.getAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *VariablesClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, _ *VariablesClientGetAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. -func (client *VariablesClient) getAtManagementGroupHandleResponse(resp *http.Response) (VariablesClientGetAtManagementGroupResponse, error) { - result := VariablesClientGetAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all variables associated with the given subscription. -// -// Generated from API version 2022-08-01-preview -// - options - VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. -func (client *VariablesClient) NewListPager(options *VariablesClientListOptions) *runtime.Pager[VariablesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[VariablesClientListResponse]{ - More: func(page VariablesClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariablesClientListResponse) (VariablesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariablesClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return VariablesClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *VariablesClient) listCreateRequest(ctx context.Context, _ *VariablesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *VariablesClient) listHandleResponse(resp *http.Response) (VariablesClientListResponse, error) { - result := VariablesClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableListResult); err != nil { - return VariablesClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all variables applicable to the management group. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - options - VariablesClientListForManagementGroupOptions contains the optional parameters for the VariablesClient.NewListForManagementGroupPager -// method. -func (client *VariablesClient) NewListForManagementGroupPager(managementGroupID string, options *VariablesClientListForManagementGroupOptions) *runtime.Pager[VariablesClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VariablesClientListForManagementGroupResponse]{ - More: func(page VariablesClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariablesClientListForManagementGroupResponse) (VariablesClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariablesClient.NewListForManagementGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) - }, nil) - if err != nil { - return VariablesClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *VariablesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, _ *VariablesClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *VariablesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariablesClientListForManagementGroupResponse, error) { - result := VariablesClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableListResult); err != nil { - return VariablesClientListForManagementGroupResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go deleted file mode 100644 index d5dd13a1db43..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariable.json -func ExampleVariablesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariablesClient().Delete(ctx, "DemoTestVariable", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariable.json -func ExampleVariablesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().CreateOrUpdate(ctx, "DemoTestVariable", armpolicy.Variable{ - Properties: &armpolicy.VariableProperties{ - Columns: []*armpolicy.VariableColumn{ - { - ColumnName: to.Ptr("TestColumn"), - }}, - }, - }, 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariable.json -func ExampleVariablesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().Get(ctx, "DemoTestVariable", 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableAtManagementGroup.json -func ExampleVariablesClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariablesClient().DeleteAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableAtManagementGroup.json -func ExampleVariablesClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().CreateOrUpdateAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", armpolicy.Variable{ - Properties: &armpolicy.VariableProperties{ - Columns: []*armpolicy.VariableColumn{ - { - ColumnName: to.Ptr("TestColumn"), - }}, - }, - }, 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableAtManagementGroup.json -func ExampleVariablesClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().GetAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariablesForSubscription.json -func ExampleVariablesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariablesClient().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.VariableListResult = armpolicy.VariableListResult{ - // Value: []*armpolicy.Variable{ - // { - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NetworkingVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/NetworkingVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("NetworkResourceName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariablesForManagementGroup.json -func ExampleVariablesClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariablesClient().NewListForManagementGroupPager("DevOrg", 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.VariableListResult = armpolicy.VariableListResult{ - // Value: []*armpolicy.Variable{ - // { - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NetworkingVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/NetworkingVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("NetworkResourceName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go deleted file mode 100644 index 9fd3cf0f9a50..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go +++ /dev/null @@ -1,550 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// VariableValuesClient contains the methods for the VariableValues group. -// Don't use this type directly, use NewVariableValuesClient() instead. -type VariableValuesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVariableValuesClient creates a new instance of VariableValuesClient 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 - pass nil to accept the default values. -func NewVariableValuesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VariableValuesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VariableValuesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a variable value with the given subscription and name for a given variable. -// Variable values are scoped to the variable for which they are created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - parameters - Parameters for the variable value. -// - options - VariableValuesClientCreateOrUpdateOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdate -// method. -func (client *VariableValuesClient) CreateOrUpdate(ctx context.Context, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateOptions) (VariableValuesClientCreateOrUpdateResponse, error) { - var err error - const operationName = "VariableValuesClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, variableName, variableValueName, parameters, options) - if err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VariableValuesClient) createOrUpdateCreateRequest(ctx context.Context, variableName string, variableValueName string, parameters VariableValue, _ *VariableValuesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *VariableValuesClient) createOrUpdateHandleResponse(resp *http.Response) (VariableValuesClientCreateOrUpdateResponse, error) { - result := VariableValuesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// CreateOrUpdateAtManagementGroup - This operation creates or updates a variable value with the given management group and -// name for a given variable. Variable values are scoped to the variable for which they are created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - parameters - Parameters for the variable value. -// - options - VariableValuesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdateAtManagementGroup -// method. -func (client *VariableValuesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.CreateOrUpdateAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, parameters, options) - if err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *VariableValuesClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters VariableValue, _ *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. -func (client *VariableValuesClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error) { - result := VariableValuesClientCreateOrUpdateAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a variable value, given its name, the subscription it was created in, and the variable -// it belongs to. The scope of a variable value is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientDeleteOptions contains the optional parameters for the VariableValuesClient.Delete method. -func (client *VariableValuesClient) Delete(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientDeleteOptions) (VariableValuesClientDeleteResponse, error) { - var err error - const operationName = "VariableValuesClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientDeleteResponse{}, err - } - return VariableValuesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VariableValuesClient) deleteCreateRequest(ctx context.Context, variableName string, variableValueName string, _ *VariableValuesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// DeleteAtManagementGroup - This operation deletes a variable value, given its name, the management group it was created -// in, and the variable it belongs to. The scope of a variable value is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.DeleteAtManagementGroup -// method. -func (client *VariableValuesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientDeleteAtManagementGroupOptions) (VariableValuesClientDeleteAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.DeleteAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - return VariableValuesClientDeleteAtManagementGroupResponse{}, nil -} - -// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *VariableValuesClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, _ *VariableValuesClientDeleteAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single variable value; given its name, subscription it was created at and the variable -// it's created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientGetOptions contains the optional parameters for the VariableValuesClient.Get method. -func (client *VariableValuesClient) Get(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientGetOptions) (VariableValuesClientGetResponse, error) { - var err error - const operationName = "VariableValuesClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VariableValuesClient) getCreateRequest(ctx context.Context, variableName string, variableValueName string, _ *VariableValuesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VariableValuesClient) getHandleResponse(resp *http.Response) (VariableValuesClientGetResponse, error) { - result := VariableValuesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientGetResponse{}, err - } - return result, nil -} - -// GetAtManagementGroup - This operation retrieves a single variable value; given its name, management group it was created -// at and the variable it's created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientGetAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.GetAtManagementGroup -// method. -func (client *VariableValuesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientGetAtManagementGroupOptions) (VariableValuesClientGetAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.GetAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - resp, err := client.getAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *VariableValuesClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, _ *VariableValuesClientGetAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. -func (client *VariableValuesClient) getAtManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientGetAtManagementGroupResponse, error) { - result := VariableValuesClientGetAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all variable values associated with the given variable that is at a -// subscription level. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.NewListPager method. -func (client *VariableValuesClient) NewListPager(variableName string, options *VariableValuesClientListOptions) *runtime.Pager[VariableValuesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[VariableValuesClientListResponse]{ - More: func(page VariableValuesClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariableValuesClientListResponse) (VariableValuesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariableValuesClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, variableName, options) - }, nil) - if err != nil { - return VariableValuesClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *VariableValuesClient) listCreateRequest(ctx context.Context, variableName string, _ *VariableValuesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *VariableValuesClient) listHandleResponse(resp *http.Response) (VariableValuesClientListResponse, error) { - result := VariableValuesClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { - return VariableValuesClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all variable values applicable the variable indicated -// at the management group scope. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariableValuesClientListForManagementGroupOptions contains the optional parameters for the VariableValuesClient.NewListForManagementGroupPager -// method. -func (client *VariableValuesClient) NewListForManagementGroupPager(managementGroupID string, variableName string, options *VariableValuesClientListForManagementGroupOptions) *runtime.Pager[VariableValuesClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VariableValuesClientListForManagementGroupResponse]{ - More: func(page VariableValuesClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariableValuesClientListForManagementGroupResponse) (VariableValuesClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariableValuesClient.NewListForManagementGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - }, nil) - if err != nil { - return VariableValuesClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *VariableValuesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, _ *VariableValuesClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *VariableValuesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientListForManagementGroupResponse, error) { - result := VariableValuesClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { - return VariableValuesClientListForManagementGroupResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go deleted file mode 100644 index e301fb8695f7..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go +++ /dev/null @@ -1,392 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableValue.json -func ExampleVariableValuesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariableValuesClient().Delete(ctx, "DemoTestVariable", "TestValue", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableValue.json -func ExampleVariableValuesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().CreateOrUpdate(ctx, "DemoTestVariable", "TestValue", armpolicy.VariableValue{ - Properties: &armpolicy.VariableValueProperties{ - Values: []*armpolicy.VariableValueColumnValue{ - { - ColumnName: to.Ptr("StringColumn"), - ColumnValue: "SampleValue", - }, - { - ColumnName: to.Ptr("IntegerColumn"), - ColumnValue: float64(10), - }}, - }, - }, 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableValue.json -func ExampleVariableValuesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().Get(ctx, "DemoTestVariable", "TestValue", 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariableValuesForSubscription.json -func ExampleVariableValuesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariableValuesClient().NewListPager("DemoTestVariable", 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.VariableValueListResult = armpolicy.VariableValueListResult{ - // Value: []*armpolicy.VariableValue{ - // { - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NullableTestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/NullableTestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("NullColumnName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariableValuesForManagementGroup.json -func ExampleVariableValuesClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariableValuesClient().NewListForManagementGroupPager("DevOrg", "DemoTestVariable", 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.VariableValueListResult = armpolicy.VariableValueListResult{ - // Value: []*armpolicy.VariableValue{ - // { - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NullableTestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/NullableTestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("NullColumnName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariableValuesClient().DeleteAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().CreateOrUpdateAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", armpolicy.VariableValue{ - Properties: &armpolicy.VariableValueProperties{ - Values: []*armpolicy.VariableValueColumnValue{ - { - ColumnName: to.Ptr("StringColumn"), - ColumnValue: "SampleValue", - }, - { - ColumnName: to.Ptr("IntegerColumn"), - ColumnValue: float64(10), - }}, - }, - }, 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().GetAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armpolicy/version.go b/sdk/resourcemanager/resources/armpolicy/version.go new file mode 100644 index 000000000000..7eb57eb6f812 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/version.go @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. + +package armpolicy + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + moduleVersion = "v1.0.0" +)