From bb216d4f2e94fca8cad507bb3081535d4d9b7961 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 14 Oct 2023 04:38:39 +0000 Subject: [PATCH] CodeGen from PR 26194 in Azure/azure-rest-api-specs Merge 1dfcc21abe6034f5c953bc8c95e6bc02e3b51e70 into fe3f311a4d963b0e9b1c39d6f3859175189f0e90 --- .../resources/armpolicy/CHANGELOG.md | 89 ++ .../resources/armpolicy/assignments_client.go | 174 +-- .../assignments_client_example_test.go | 1067 ----------------- .../resources/armpolicy/autorest.md | 6 +- .../resources/armpolicy/client_factory.go | 50 +- .../resources/armpolicy/constants.go | 83 +- .../armpolicy/datapolicymanifests_client.go | 14 +- ...datapolicymanifests_client_example_test.go | 278 ----- .../resources/armpolicy/definitions_client.go | 192 +-- .../definitions_client_example_test.go | 806 ------------- .../armpolicy/definitionversions_client.go | 789 ++++++++++++ .../resources/armpolicy/exemptions_client.go | 138 ++- .../exemptions_client_example_test.go | 432 ------- .../resources/armpolicy/go.mod | 12 +- .../resources/armpolicy/go.sum | 20 +- .../resources/armpolicy/models.go | 581 ++++----- .../resources/armpolicy/models_serde.go | 753 +++++++++++- .../resources/armpolicy/options.go | 628 ++++++++++ .../resources/armpolicy/response_types.go | 289 ++++- .../armpolicy/setdefinitions_client.go | 192 +-- .../setdefinitions_client_example_test.go | 1028 ---------------- .../armpolicy/setdefinitionversions_client.go | 792 ++++++++++++ .../resources/armpolicy/time_rfc3339.go | 3 +- .../resources/armpolicy/variables_client.go | 484 ++++++++ .../armpolicy/variablevalues_client.go | 527 ++++++++ 25 files changed, 5136 insertions(+), 4291 deletions(-) delete mode 100644 sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go create mode 100644 sdk/resourcemanager/resources/armpolicy/definitionversions_client.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go create mode 100644 sdk/resourcemanager/resources/armpolicy/options.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go create mode 100644 sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go create mode 100644 sdk/resourcemanager/resources/armpolicy/variables_client.go create mode 100644 sdk/resourcemanager/resources/armpolicy/variablevalues_client.go diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index 280084c8f79c..c1b782085b9f 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,94 @@ # Release History +## 0.8.0 (2023-10-14) +### Breaking Changes + +- Function `NewClientFactory` parameter(s) have been changed from `(string, azcore.TokenCredential, *arm.ClientOptions)` to `(string, string, string, string, azcore.TokenCredential, *arm.ClientOptions)` + +### Features Added + +- New enum type `AssignmentScopeValidation` with values `AssignmentScopeValidationDefault`, `AssignmentScopeValidationDoNotValidate` +- New enum type `OverrideKind` with values `OverrideKindPolicyEffect` +- New enum type `SelectorKind` with values `SelectorKindPolicyDefinitionReferenceID`, `SelectorKindResourceLocation`, `SelectorKindResourceType`, `SelectorKindResourceWithoutLocation` +- New function `*ClientFactory.NewDefinitionVersionsClient() *DefinitionVersionsClient` +- New function `*ClientFactory.NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient` +- New function `*ClientFactory.NewVariableValuesClient() *VariableValuesClient` +- New function `*ClientFactory.NewVariablesClient() *VariablesClient` +- New function `NewDefinitionVersionsClient(string, string, string, azcore.TokenCredential, *arm.ClientOptions) (*DefinitionVersionsClient, error)` +- New function `*DefinitionVersionsClient.CreateOrUpdate(context.Context, DefinitionVersion, *DefinitionVersionsClientCreateOrUpdateOptions) (DefinitionVersionsClientCreateOrUpdateResponse, error)` +- New function `*DefinitionVersionsClient.CreateOrUpdateAtManagementGroup(context.Context, string, DefinitionVersion, *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.Delete(context.Context, *DefinitionVersionsClientDeleteOptions) (DefinitionVersionsClientDeleteResponse, error)` +- New function `*DefinitionVersionsClient.DeleteAtManagementGroup(context.Context, string, *DefinitionVersionsClientDeleteAtManagementGroupOptions) (DefinitionVersionsClientDeleteAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.Get(context.Context, *DefinitionVersionsClientGetOptions) (DefinitionVersionsClientGetResponse, error)` +- New function `*DefinitionVersionsClient.GetAtManagementGroup(context.Context, string, *DefinitionVersionsClientGetAtManagementGroupOptions) (DefinitionVersionsClientGetAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.GetBuiltIn(context.Context, *DefinitionVersionsClientGetBuiltInOptions) (DefinitionVersionsClientGetBuiltInResponse, error)` +- New function `*DefinitionVersionsClient.ListAll(context.Context, *DefinitionVersionsClientListAllOptions) (DefinitionVersionsClientListAllResponse, error)` +- New function `*DefinitionVersionsClient.ListAllAtManagementGroup(context.Context, string, *DefinitionVersionsClientListAllAtManagementGroupOptions) (DefinitionVersionsClientListAllAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.ListAllBuiltins(context.Context, *DefinitionVersionsClientListAllBuiltinsOptions) (DefinitionVersionsClientListAllBuiltinsResponse, error)` +- New function `*DefinitionVersionsClient.NewListBuiltInPager(*DefinitionVersionsClientListBuiltInOptions) *runtime.Pager[DefinitionVersionsClientListBuiltInResponse]` +- New function `*DefinitionVersionsClient.NewListByManagementGroupPager(string, *DefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionVersionsClientListByManagementGroupResponse]` +- New function `*DefinitionVersionsClient.NewListPager(*DefinitionVersionsClientListOptions) *runtime.Pager[DefinitionVersionsClientListResponse]` +- New function `*ExemptionsClient.Update(context.Context, string, string, ExemptionUpdate, *ExemptionsClientUpdateOptions) (ExemptionsClientUpdateResponse, error)` +- New function `NewSetDefinitionVersionsClient(string, string, string, azcore.TokenCredential, *arm.ClientOptions) (*SetDefinitionVersionsClient, error)` +- New function `*SetDefinitionVersionsClient.CreateOrUpdate(context.Context, SetDefinitionVersion, *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error)` +- New function `*SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup(context.Context, string, SetDefinitionVersion, *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.Delete(context.Context, *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error)` +- New function `*SetDefinitionVersionsClient.DeleteAtManagementGroup(context.Context, string, *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.Get(context.Context, *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error)` +- New function `*SetDefinitionVersionsClient.GetAtManagementGroup(context.Context, string, *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.GetBuiltIn(context.Context, *SetDefinitionVersionsClientGetBuiltInOptions) (SetDefinitionVersionsClientGetBuiltInResponse, error)` +- New function `*SetDefinitionVersionsClient.ListAll(context.Context, *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error)` +- New function `*SetDefinitionVersionsClient.ListAllAtManagementGroup(context.Context, string, *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.ListAllBuiltins(context.Context, *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error)` +- New function `*SetDefinitionVersionsClient.NewListBuiltInPager(*SetDefinitionVersionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionVersionsClientListBuiltInResponse]` +- New function `*SetDefinitionVersionsClient.NewListByManagementGroupPager(string, *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse]` +- New function `*SetDefinitionVersionsClient.NewListPager(*SetDefinitionVersionsClientListOptions) *runtime.Pager[SetDefinitionVersionsClientListResponse]` +- New function `NewVariableValuesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*VariableValuesClient, error)` +- New function `*VariableValuesClient.CreateOrUpdate(context.Context, string, string, VariableValue, *VariableValuesClientCreateOrUpdateOptions) (VariableValuesClientCreateOrUpdateResponse, error)` +- New function `*VariableValuesClient.CreateOrUpdateAtManagementGroup(context.Context, string, string, string, VariableValue, *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.Delete(context.Context, string, string, *VariableValuesClientDeleteOptions) (VariableValuesClientDeleteResponse, error)` +- New function `*VariableValuesClient.DeleteAtManagementGroup(context.Context, string, string, string, *VariableValuesClientDeleteAtManagementGroupOptions) (VariableValuesClientDeleteAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.Get(context.Context, string, string, *VariableValuesClientGetOptions) (VariableValuesClientGetResponse, error)` +- New function `*VariableValuesClient.GetAtManagementGroup(context.Context, string, string, string, *VariableValuesClientGetAtManagementGroupOptions) (VariableValuesClientGetAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.NewListForManagementGroupPager(string, string, *VariableValuesClientListForManagementGroupOptions) *runtime.Pager[VariableValuesClientListForManagementGroupResponse]` +- New function `*VariableValuesClient.NewListPager(string, *VariableValuesClientListOptions) *runtime.Pager[VariableValuesClientListResponse]` +- New function `NewVariablesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*VariablesClient, error)` +- New function `*VariablesClient.CreateOrUpdate(context.Context, string, Variable, *VariablesClientCreateOrUpdateOptions) (VariablesClientCreateOrUpdateResponse, error)` +- New function `*VariablesClient.CreateOrUpdateAtManagementGroup(context.Context, string, string, Variable, *VariablesClientCreateOrUpdateAtManagementGroupOptions) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*VariablesClient.Delete(context.Context, string, *VariablesClientDeleteOptions) (VariablesClientDeleteResponse, error)` +- New function `*VariablesClient.DeleteAtManagementGroup(context.Context, string, string, *VariablesClientDeleteAtManagementGroupOptions) (VariablesClientDeleteAtManagementGroupResponse, error)` +- New function `*VariablesClient.Get(context.Context, string, *VariablesClientGetOptions) (VariablesClientGetResponse, error)` +- New function `*VariablesClient.GetAtManagementGroup(context.Context, string, string, *VariablesClientGetAtManagementGroupOptions) (VariablesClientGetAtManagementGroupResponse, error)` +- New function `*VariablesClient.NewListForManagementGroupPager(string, *VariablesClientListForManagementGroupOptions) *runtime.Pager[VariablesClientListForManagementGroupResponse]` +- New function `*VariablesClient.NewListPager(*VariablesClientListOptions) *runtime.Pager[VariablesClientListResponse]` +- New struct `AssignmentUpdateProperties` +- New struct `DefinitionVersion` +- New struct `DefinitionVersionListResult` +- New struct `DefinitionVersionProperties` +- New struct `ExemptionUpdate` +- New struct `ExemptionUpdateProperties` +- New struct `Override` +- New struct `ResourceSelector` +- New struct `Selector` +- New struct `SetDefinitionVersion` +- New struct `SetDefinitionVersionListResult` +- New struct `SetDefinitionVersionProperties` +- New struct `Variable` +- New struct `VariableColumn` +- New struct `VariableListResult` +- New struct `VariableProperties` +- New struct `VariableValue` +- New struct `VariableValueColumnValue` +- New struct `VariableValueListResult` +- New struct `VariableValueProperties` +- New field `Overrides`, `ResourceSelectors` in struct `AssignmentProperties` +- New field `Properties` in struct `AssignmentUpdate` +- New field `Version`, `Versions` in struct `DefinitionProperties` +- New field `AssignmentScopeValidation`, `ResourceSelectors` in struct `ExemptionProperties` +- New field `Schema` in struct `ParameterDefinitionsValue` +- New field `Version`, `Versions` in struct `SetDefinitionProperties` + + ## 0.7.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client.go b/sdk/resourcemanager/resources/armpolicy/assignments_client.go index b37a2d5eaeb2..aa04d160ad5f 100644 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client.go +++ b/sdk/resourcemanager/resources/armpolicy/assignments_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -30,7 +29,7 @@ type AssignmentsClient struct { } // NewAssignmentsClient creates a new instance of AssignmentsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsClient, error) { @@ -50,7 +49,7 @@ func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredenti // 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 2021-06-01 +// 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}', @@ -60,18 +59,21 @@ func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredenti // - 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) { + var err error req, err := client.createCreateRequest(ctx, scope, policyAssignmentName, parameters, options) if err != nil { return AssignmentsClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return AssignmentsClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -87,10 +89,13 @@ func (client *AssignmentsClient) createCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createHandleResponse handles the Create response. @@ -112,23 +117,26 @@ func (client *AssignmentsClient) createHandleResponse(resp *http.Response) (Assi // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// 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}'. // - 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) { + var err error req, err := client.createByIDCreateRequest(ctx, policyAssignmentID, parameters, options) if err != nil { return AssignmentsClientCreateByIDResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientCreateByIDResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return AssignmentsClientCreateByIDResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientCreateByIDResponse{}, err } - return client.createByIDHandleResponse(resp) + resp, err := client.createByIDHandleResponse(httpResp) + return resp, err } // createByIDCreateRequest creates the CreateByID request. @@ -140,10 +148,13 @@ func (client *AssignmentsClient) createByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createByIDHandleResponse handles the CreateByID response. @@ -160,7 +171,7 @@ func (client *AssignmentsClient) createByIDHandleResponse(resp *http.Response) ( // '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// 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}', @@ -169,18 +180,21 @@ func (client *AssignmentsClient) createByIDHandleResponse(resp *http.Response) ( // - policyAssignmentName - The name of the policy assignment to delete. // - 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 req, err := client.deleteCreateRequest(ctx, scope, policyAssignmentName, options) if err != nil { return AssignmentsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return AssignmentsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -196,7 +210,7 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -220,22 +234,25 @@ func (client *AssignmentsClient) deleteHandleResponse(resp *http.Response) (Assi // (resource). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// 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}'. // - 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 req, err := client.deleteByIDCreateRequest(ctx, policyAssignmentID, options) if err != nil { return AssignmentsClientDeleteByIDResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientDeleteByIDResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return AssignmentsClientDeleteByIDResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientDeleteByIDResponse{}, err } - return client.deleteByIDHandleResponse(resp) + resp, err := client.deleteByIDHandleResponse(httpResp) + return resp, err } // deleteByIDCreateRequest creates the DeleteByID request. @@ -247,7 +264,7 @@ func (client *AssignmentsClient) deleteByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -265,7 +282,7 @@ 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 2021-06-01 +// 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}', @@ -274,18 +291,21 @@ func (client *AssignmentsClient) deleteByIDHandleResponse(resp *http.Response) ( // - 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) { + var err error req, err := client.getCreateRequest(ctx, scope, policyAssignmentName, options) if err != nil { return AssignmentsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AssignmentsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -301,7 +321,7 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -324,22 +344,25 @@ func (client *AssignmentsClient) getHandleResponse(resp *http.Response) (Assignm // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-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) { + var err error req, err := client.getByIDCreateRequest(ctx, policyAssignmentID, options) if err != nil { return AssignmentsClientGetByIDResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientGetByIDResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AssignmentsClientGetByIDResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientGetByIDResponse{}, err } - return client.getByIDHandleResponse(resp) + resp, err := client.getByIDHandleResponse(httpResp) + return resp, err } // getByIDCreateRequest creates the GetByID request. @@ -351,7 +374,7 @@ func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, polic return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -378,7 +401,7 @@ func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (Ass // is provided, the returned list includes all policy assignments of the policy // definition whose id is {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-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]{ @@ -411,9 +434,6 @@ func (client *AssignmentsClient) NewListPager(options *AssignmentsClientListOpti // listCreateRequest creates the List request. func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options *AssignmentsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" - 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 { @@ -423,7 +443,7 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -451,7 +471,7 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign // 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 2021-06-01 +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. // - options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager // method. @@ -498,7 +518,7 @@ func (client *AssignmentsClient) listForManagementGroupCreateRequest(ctx context if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -540,7 +560,7 @@ func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http // format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, // {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - 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) @@ -580,6 +600,7 @@ func (client *AssignmentsClient) NewListForResourcePager(resourceGroupName strin // listForResourceCreateRequest creates the ListForResource request. func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *AssignmentsClientListForResourceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -594,10 +615,6 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 @@ -606,7 +623,7 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -638,7 +655,7 @@ func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Respon // 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 2021-06-01 +// Generated from API version 2023-04-01 // - resourceGroupName - The name of the resource group that contains policy assignments. // - options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager // method. @@ -673,14 +690,11 @@ func (client *AssignmentsClient) NewListForResourceGroupPager(resourceGroupName // listForResourceGroupCreateRequest creates the ListForResourceGroup request. func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AssignmentsClientListForResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments" + 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 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 @@ -689,7 +703,7 @@ func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.C if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -714,7 +728,7 @@ func (client *AssignmentsClient) listForResourceGroupHandleResponse(resp *http.R // 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 2021-06-01 +// 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}', @@ -724,18 +738,21 @@ func (client *AssignmentsClient) listForResourceGroupHandleResponse(resp *http.R // - 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) { + var err error req, err := client.updateCreateRequest(ctx, scope, policyAssignmentName, parameters, options) if err != nil { return AssignmentsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AssignmentsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -751,10 +768,13 @@ func (client *AssignmentsClient) updateCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. @@ -776,23 +796,26 @@ func (client *AssignmentsClient) updateHandleResponse(resp *http.Response) (Assi // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// 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}'. // - 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) { + var err error req, err := client.updateByIDCreateRequest(ctx, policyAssignmentID, parameters, options) if err != nil { return AssignmentsClientUpdateByIDResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientUpdateByIDResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AssignmentsClientUpdateByIDResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AssignmentsClientUpdateByIDResponse{}, err } - return client.updateByIDHandleResponse(resp) + resp, err := client.updateByIDHandleResponse(httpResp) + return resp, err } // updateByIDCreateRequest creates the UpdateByID request. @@ -804,10 +827,13 @@ func (client *AssignmentsClient) updateByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // updateByIDHandleResponse handles the UpdateByID response. diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go deleted file mode 100644 index ab4475d173e9..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go +++ /dev/null @@ -1,1067 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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"), - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - }}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}, - }, - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "securityInitAssignment", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - DisplayName: to.Ptr("Enforce security policies"), - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resources must comply with all internal security policies. See for more info."), - }, - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - PolicyDefinitionReferenceID: to.Ptr("10420126870854049575"), - }, - { - Message: to.Ptr("Storage accounts must have firewall rules configured."), - PolicyDefinitionReferenceID: to.Ptr("8572513655450389710"), - }}, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDoNotEnforce), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.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"), - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.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"), - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - // "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{ - // ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // }, - // }, - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.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"), - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}, - }, - }, - Location: to.Ptr("eastus"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - // "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{ - // ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // }, - // }, - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.AssignmentsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()"), - 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.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"), - // DisplayName: to.Ptr("Storage Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // 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"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - 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, - 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.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"), - // DisplayName: to.Ptr("VM Cost Management"), - // 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/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"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // 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"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForManagementGroupPager("TestManagementGroup", &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()"), - 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.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"), - // DisplayName: to.Ptr("Storage Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // 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"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // NotScopes: []*string{ - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListPager(&armpolicy.AssignmentsClientListOptions{Filter: to.Ptr("atScope()"), - 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.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"), - // DisplayName: to.Ptr("Storage Cost Management"), - // 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"), - // }, - // }, - // { - // 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"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // 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"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignmentById.json -func ExampleAssignmentsClient_DeleteByID() { - 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().DeleteByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", 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"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // 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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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"), - 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentWithAManagedIdentityById() { - 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{ - 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"), - 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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", 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"), - // 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", - // }, - // }, - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentWithAManagedIdentityById() { - 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", 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"), - // 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", - // }, - // }, - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_UpdateByID() { - 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().UpdateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", 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"), - // 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"), - // 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", - // }, - // }, - // }, - // 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 index 2a17980c1ad9..79789a879d26 100644 --- a/sdk/resourcemanager/resources/armpolicy/autorest.md +++ b/sdk/resourcemanager/resources/armpolicy/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.7.1 +module-version: 0.8.0 package-policy: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/client_factory.go b/sdk/resourcemanager/resources/armpolicy/client_factory.go index 30a6d2e1e6fa..ed8a39151707 100644 --- a/sdk/resourcemanager/resources/armpolicy/client_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/client_factory.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -17,34 +16,46 @@ import ( // ClientFactory is a client factory used to create any client in this module. // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { - subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + subscriptionID string + policyDefinitionName string + policyDefinitionVersion string + policySetDefinitionName string + credential azcore.TokenCredential + options *arm.ClientOptions } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - 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 +// - policySetDefinitionName - The name of the policy set definition. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { +func NewClientFactory(subscriptionID string, policyDefinitionName string, policyDefinitionVersion string, policySetDefinitionName string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, + subscriptionID: subscriptionID, policyDefinitionName: policyDefinitionName, policyDefinitionVersion: policyDefinitionVersion, policySetDefinitionName: policySetDefinitionName, credential: credential, options: options.Clone(), }, nil } +func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { + subClient, _ := NewAssignmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewDataPolicyManifestsClient() *DataPolicyManifestsClient { subClient, _ := NewDataPolicyManifestsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { - subClient, _ := NewAssignmentsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewDefinitionVersionsClient() *DefinitionVersionsClient { + subClient, _ := NewDefinitionVersionsClient(c.subscriptionID, c.policyDefinitionName, c.policyDefinitionVersion, c.credential, c.options) return subClient } @@ -53,12 +64,27 @@ func (c *ClientFactory) NewDefinitionsClient() *DefinitionsClient { return subClient } +func (c *ClientFactory) NewExemptionsClient() *ExemptionsClient { + subClient, _ := NewExemptionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient { + subClient, _ := NewSetDefinitionVersionsClient(c.subscriptionID, c.policySetDefinitionName, c.policyDefinitionVersion, c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewSetDefinitionsClient() *SetDefinitionsClient { subClient, _ := NewSetDefinitionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewExemptionsClient() *ExemptionsClient { - subClient, _ := NewExemptionsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVariableValuesClient() *VariableValuesClient { + subClient, _ := NewVariableValuesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVariablesClient() *VariablesClient { + subClient, _ := NewVariablesClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/resources/armpolicy/constants.go b/sdk/resourcemanager/resources/armpolicy/constants.go index c65091adc04e..9e242c7b3f40 100644 --- a/sdk/resourcemanager/resources/armpolicy/constants.go +++ b/sdk/resourcemanager/resources/armpolicy/constants.go @@ -3,15 +3,14 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy const ( moduleName = "armpolicy" - moduleVersion = "v0.7.1" + moduleVersion = "v0.8.0" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to. @@ -72,17 +71,17 @@ func PossibleAliasPathTokenTypeValues() []AliasPathTokenType { type AliasPatternType string const ( - // AliasPatternTypeNotSpecified - NotSpecified is not allowed. - AliasPatternTypeNotSpecified AliasPatternType = "NotSpecified" // 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{ - AliasPatternTypeNotSpecified, AliasPatternTypeExtract, + AliasPatternTypeNotSpecified, } } @@ -90,20 +89,39 @@ func PossibleAliasPatternTypeValues() []AliasPatternType { type AliasType 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" - // AliasTypeMask - Alias value is secret. - AliasTypeMask AliasType = "Mask" ) // PossibleAliasTypeValues returns the possible values for the AliasType const type. func PossibleAliasTypeValues() []AliasType { return []AliasType{ + AliasTypeMask, AliasTypeNotSpecified, AliasTypePlainText, - AliasTypeMask, + } +} + +// 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, } } @@ -164,6 +182,21 @@ func PossibleExemptionCategoryValues() []ExemptionCategory { } } +// OverrideKind - The override kind. +type OverrideKind string + +const ( + // OverrideKindPolicyEffect - It will override the policy effect type. + OverrideKindPolicyEffect OverrideKind = "policyEffect" +) + +// PossibleOverrideKindValues returns the possible values for the OverrideKind const type. +func PossibleOverrideKindValues() []OverrideKind { + return []OverrideKind{ + OverrideKindPolicyEffect, + } +} + // ParameterType - The data type of the parameter. type ParameterType string @@ -215,20 +248,44 @@ func PossiblePolicyTypeValues() []PolicyType { type ResourceIdentityType string const ( + // ResourceIdentityTypeNone - Indicates that no identity is associated with the resource or that the existing identity should + // be removed. + ResourceIdentityTypeNone ResourceIdentityType = "None" // ResourceIdentityTypeSystemAssigned - Indicates that a system assigned identity is associated with the resource. ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" // ResourceIdentityTypeUserAssigned - Indicates that a system assigned identity is associated with the resource. ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" - // ResourceIdentityTypeNone - Indicates that no identity is associated with the resource or that the existing identity should - // be removed. - ResourceIdentityTypeNone ResourceIdentityType = "None" ) // PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. func PossibleResourceIdentityTypeValues() []ResourceIdentityType { return []ResourceIdentityType{ + ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, ResourceIdentityTypeUserAssigned, - ResourceIdentityTypeNone, + } +} + +// SelectorKind - The selector kind. +type SelectorKind string + +const ( + // SelectorKindPolicyDefinitionReferenceID - The selector kind to filter policies by the policy definition reference ID. + SelectorKindPolicyDefinitionReferenceID SelectorKind = "policyDefinitionReferenceId" + // SelectorKindResourceLocation - The selector kind to filter policies by the resource location. + SelectorKindResourceLocation SelectorKind = "resourceLocation" + // SelectorKindResourceType - The selector kind to filter policies by the resource type. + SelectorKindResourceType SelectorKind = "resourceType" + // SelectorKindResourceWithoutLocation - The selector kind to filter policies by the resource without location. + SelectorKindResourceWithoutLocation SelectorKind = "resourceWithoutLocation" +) + +// PossibleSelectorKindValues returns the possible values for the SelectorKind const type. +func PossibleSelectorKindValues() []SelectorKind { + return []SelectorKind{ + SelectorKindPolicyDefinitionReferenceID, + SelectorKindResourceLocation, + SelectorKindResourceType, + SelectorKindResourceWithoutLocation, } } diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go index 18acf02c2615..eb85a599d8c7 100644 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go +++ b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -49,18 +48,21 @@ func NewDataPolicyManifestsClient(credential azcore.TokenCredential, options *ar // - 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 req, err := client.getByPolicyModeCreateRequest(ctx, policyMode, options) if err != nil { return DataPolicyManifestsClientGetByPolicyModeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DataPolicyManifestsClientGetByPolicyModeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataPolicyManifestsClientGetByPolicyModeResponse{}, err } - return client.getByPolicyModeHandleResponse(resp) + resp, err := client.getByPolicyModeHandleResponse(httpResp) + return resp, err } // getByPolicyModeCreateRequest creates the GetByPolicyMode request. 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 d893eddbcb04..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go +++ /dev/null @@ -1,278 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/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/d55b8005f05b040b852c15e74a0f3e36494a15e1/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/d55b8005f05b040b852c15e74a0f3e36494a15e1/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 271def0addc6..b96aec7441ed 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitions_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -30,7 +29,7 @@ type DefinitionsClient struct { } // NewDefinitionsClient creates a new instance of DefinitionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionsClient, error) { @@ -48,46 +47,49 @@ 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 2021-06-01 +// Generated from API version 2023-04-01 // - policyDefinitionName - The name of the policy definition to create. // - parameters - The policy definition properties. // - options - DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate // method. func (client *DefinitionsClient) CreateOrUpdate(ctx context.Context, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateOptions) (DefinitionsClientCreateOrUpdateResponse, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, policyDefinitionName, parameters, options) if err != nil { return DefinitionsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return DefinitionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *DefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) - 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.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -103,47 +105,53 @@ func (client *DefinitionsClient) createOrUpdateHandleResponse(resp *http.Respons // the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policyDefinitionName - The name of the policy definition to create. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policyDefinitionName - The name of the policy definition to create. // - parameters - The policy definition properties. // - options - DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup // method. -func (client *DefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, policyDefinitionName, managementGroupID, parameters, options) +func (client *DefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { + var err error + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, policyDefinitionName, parameters, options) if err != nil { return DefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return DefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } - return client.createOrUpdateAtManagementGroupHandleResponse(resp) + resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) + return resp, err } // createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { +func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. @@ -158,20 +166,22 @@ 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 2021-06-01 +// Generated from API version 2023-04-01 // - policyDefinitionName - The name of the policy definition to delete. // - 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 req, err := client.deleteCreateRequest(ctx, policyDefinitionName, options) if err != nil { return DefinitionsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return DefinitionsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientDeleteResponse{}, err } return DefinitionsClientDeleteResponse{}, nil } @@ -179,20 +189,17 @@ func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionNam // deleteCreateRequest creates the Delete request. func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policyDefinitionName string, options *DefinitionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) - 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.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -201,43 +208,45 @@ func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policy // 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 2021-06-01 -// - policyDefinitionName - The name of the policy definition to delete. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policyDefinitionName - The name of the policy definition to delete. // - options - DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup // method. -func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientDeleteAtManagementGroupOptions) (DefinitionsClientDeleteAtManagementGroupResponse, error) { - req, err := client.deleteAtManagementGroupCreateRequest(ctx, policyDefinitionName, managementGroupID, options) +func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientDeleteAtManagementGroupOptions) (DefinitionsClientDeleteAtManagementGroupResponse, error) { + var err error + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, policyDefinitionName, options) if err != nil { return DefinitionsClientDeleteAtManagementGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientDeleteAtManagementGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return DefinitionsClientDeleteAtManagementGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientDeleteAtManagementGroupResponse{}, err } return DefinitionsClientDeleteAtManagementGroupResponse{}, nil } // deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { +func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,41 +255,41 @@ func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx contex // 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 2021-06-01 +// Generated from API version 2023-04-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) { + var err error req, err := client.getCreateRequest(ctx, policyDefinitionName, options) if err != nil { return DefinitionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefinitionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *DefinitionsClient) getCreateRequest(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) - 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -298,43 +307,46 @@ 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 2021-06-01 -// - policyDefinitionName - The name of the policy definition to get. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policyDefinitionName - The name of the policy definition to get. // - options - DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup // method. -func (client *DefinitionsClient) GetAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientGetAtManagementGroupOptions) (DefinitionsClientGetAtManagementGroupResponse, error) { - req, err := client.getAtManagementGroupCreateRequest(ctx, policyDefinitionName, managementGroupID, options) +func (client *DefinitionsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientGetAtManagementGroupOptions) (DefinitionsClientGetAtManagementGroupResponse, error) { + var err error + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, policyDefinitionName, options) if err != nil { return DefinitionsClientGetAtManagementGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientGetAtManagementGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefinitionsClientGetAtManagementGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientGetAtManagementGroupResponse{}, err } - return client.getAtManagementGroupHandleResponse(resp) + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err } // getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { +func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -352,22 +364,25 @@ 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 2021-06-01 +// Generated from API version 2023-04-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) { + var err error req, err := client.getBuiltInCreateRequest(ctx, policyDefinitionName, options) if err != nil { return DefinitionsClientGetBuiltInResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefinitionsClientGetBuiltInResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefinitionsClientGetBuiltInResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionsClientGetBuiltInResponse{}, err } - return client.getBuiltInHandleResponse(resp) + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err } // getBuiltInCreateRequest creates the GetBuiltIn request. @@ -382,7 +397,7 @@ func (client *DefinitionsClient) getBuiltInCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -407,7 +422,7 @@ func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) ( // 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 2021-06-01 +// Generated from API version 2023-04-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]{ @@ -440,16 +455,13 @@ func (client *DefinitionsClient) NewListPager(options *DefinitionsClientListOpti // listCreateRequest creates the List request. func (client *DefinitionsClient) listCreateRequest(ctx context.Context, options *DefinitionsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" - 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } @@ -478,7 +490,7 @@ func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (Defini // 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 2021-06-01 +// Generated from API version 2023-04-01 // - options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager // method. func (client *DefinitionsClient) NewListBuiltInPager(options *DefinitionsClientListBuiltInOptions) *runtime.Pager[DefinitionsClientListBuiltInResponse] { @@ -517,7 +529,7 @@ func (client *DefinitionsClient) listBuiltInCreateRequest(ctx context.Context, o return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } @@ -551,7 +563,7 @@ func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) // 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 2021-06-01 +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. // - options - DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager // method. @@ -595,7 +607,7 @@ func (client *DefinitionsClient) listByManagementGroupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go deleted file mode 100644 index c60b1345b336..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go +++ /dev/null @@ -1,806 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "ResourceNaming", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "EventHubDiagnosticLogs", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised"), - DisplayName: to.Ptr("Event Hubs should have diagnostic logging enabled"), - Metadata: map[string]any{ - "category": "Event Hub", - }, - Mode: to.Ptr("Indexed"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "requiredRetentionDays": { - Type: to.Ptr(armpolicy.ParameterTypeInteger), - AllowedValues: []any{ - float64(0), - float64(30), - float64(90), - float64(180), - float64(365)}, - DefaultValue: float64(365), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("The required diagnostic logs retention in days"), - DisplayName: to.Ptr("Required retention (days)"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "equals": "Microsoft.EventHub/namespaces", - "field": "type", - }, - "then": map[string]any{ - "effect": "AuditIfNotExists", - "details": map[string]any{ - "type": "Microsoft.Insights/diagnosticSettings", - "existenceCondition": map[string]any{ - "allOf": []any{ - map[string]any{ - "equals": "true", - "field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", - }, - map[string]any{ - "equals": "[parameters('requiredRetentionDays')]", - "field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", - }, - }, - }, - }, - }, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().Get(ctx, "ResourceNaming", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.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), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "ResourceNaming", "MyManagementGroup", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().DeleteAtManagementGroup(ctx, "ResourceNaming", "MyManagementGroup", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().GetAtManagementGroup(ctx, "ResourceNaming", "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.Definition = armpolicy.Definition{ - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListPager(&armpolicy.DefinitionsClientListOptions{Filter: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // 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), - // }, - // }, - // { - // Name: to.Ptr("AuditSoonToExpireCerts"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/AuditSoonToExpireCerts"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."), - // DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"), - // Metadata: map[string]any{ - // "category": "KeyVault DataPlane", - // }, - // Mode: to.Ptr("Microsoft.KeyVault.Data"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "daysToExpire": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeInteger), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The number of days for a certificate to expire."), - // DisplayName: to.Ptr("Days to expire"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn", - // "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]", - // }, - // "then":map[string]any{ - // "effect": "audit", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListBuiltInPager(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("06a78e20-9358-41c9-923c-fb736d382a12"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeStatic), - // }, - // }, - // { - // 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), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go new file mode 100644 index 000000000000..70b1783ba407 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go @@ -0,0 +1,789 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. 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" + "strconv" + "strings" +) + +// DefinitionVersionsClient contains the methods for the PolicyDefinitionVersions group. +// Don't use this type directly, use NewDefinitionVersionsClient() instead. +type DefinitionVersionsClient struct { + internal *arm.Client + subscriptionID string + policyDefinitionName string + policyDefinitionVersion string +} + +// NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - 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 +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDefinitionVersionsClient(subscriptionID string, policyDefinitionName string, policyDefinitionVersion string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionVersionsClient, error) { + cl, err := arm.NewClient(moduleName+".DefinitionVersionsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DefinitionVersionsClient{ + subscriptionID: subscriptionID, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + internal: cl, + } + return client, nil +} + +// 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 +// - parameters - The policy definition properties. +// - options - DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate +// method. +func (client *DefinitionVersionsClient) CreateOrUpdate(ctx context.Context, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateOptions) (DefinitionVersionsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, parameters, options) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DefinitionVersionsClient) createOrUpdateCreateRequest(ctx context.Context, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 *DefinitionVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (DefinitionVersionsClientCreateOrUpdateResponse, error) { + result := DefinitionVersionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// CreateOrUpdateAtManagementGroup - This operation creates or updates a policy definition version in the given management +// group with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - parameters - The policy definition properties. +// - options - DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +func (client *DefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + var err error + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupName, parameters, options) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. +func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 *DefinitionVersionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + result := DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + return result, nil +} + +// 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 +// - options - DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete +// method. +func (client *DefinitionVersionsClient) Delete(ctx context.Context, options *DefinitionVersionsClientDeleteOptions) (DefinitionVersionsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientDeleteResponse{}, err + } + return DefinitionVersionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DefinitionVersionsClient) deleteCreateRequest(ctx context.Context, options *DefinitionVersionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup +// method. +func (client *DefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientDeleteAtManagementGroupOptions) (DefinitionVersionsClientDeleteAtManagementGroupResponse, error) { + var err error + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, nil +} + +// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. +func (client *DefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 +// - options - DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method. +func (client *DefinitionVersionsClient) Get(ctx context.Context, options *DefinitionVersionsClientGetOptions) (DefinitionVersionsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DefinitionVersionsClient) getCreateRequest(ctx context.Context, options *DefinitionVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DefinitionVersionsClient) getHandleResponse(resp *http.Response) (DefinitionVersionsClientGetResponse, error) { + result := DefinitionVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientGetResponse{}, err + } + return result, nil +} + +// GetAtManagementGroup - This operation retrieves the policy definition version in the given management group with the given +// name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup +// method. +func (client *DefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientGetAtManagementGroupOptions) (DefinitionVersionsClientGetAtManagementGroupResponse, error) { + var err error + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. +func (client *DefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientGetAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. +func (client *DefinitionVersionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientGetAtManagementGroupResponse, error) { + result := DefinitionVersionsClientGetAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + return result, nil +} + +// 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 +// - options - DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn +// method. +func (client *DefinitionVersionsClient) GetBuiltIn(ctx context.Context, options *DefinitionVersionsClientGetBuiltInOptions) (DefinitionVersionsClientGetBuiltInResponse, error) { + var err error + req, err := client.getBuiltInCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *DefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Context, options *DefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBuiltInHandleResponse handles the GetBuiltIn response. +func (client *DefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Response) (DefinitionVersionsClientGetBuiltInResponse, error) { + result := DefinitionVersionsClientGetBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + return result, nil +} + +// NewListPager - This operation retrieves a list of all the policy definition versions for the given policy definition. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager +// method. +func (client *DefinitionVersionsClient) NewListPager(options *DefinitionVersionsClientListOptions) *runtime.Pager[DefinitionVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DefinitionVersionsClientListResponse]{ + More: func(page DefinitionVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefinitionVersionsClientListResponse) (DefinitionVersionsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DefinitionVersionsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DefinitionVersionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *DefinitionVersionsClient) listCreateRequest(ctx context.Context, options *DefinitionVersionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + 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", "2023-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DefinitionVersionsClient) listHandleResponse(resp *http.Response) (DefinitionVersionsClientListResponse, error) { + result := DefinitionVersionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListResponse{}, err + } + return result, nil +} + +// ListAll - 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 +// - options - DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll +// method. +func (client *DefinitionVersionsClient) ListAll(ctx context.Context, options *DefinitionVersionsClientListAllOptions) (DefinitionVersionsClientListAllResponse, error) { + var err error + req, err := client.listAllCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientListAllResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListAllResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientListAllResponse{}, err + } + resp, err := client.listAllHandleResponse(httpResp) + return resp, err +} + +// listAllCreateRequest creates the ListAll request. +func (client *DefinitionVersionsClient) listAllCreateRequest(ctx context.Context, options *DefinitionVersionsClientListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicyDefinitionVersions" + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *DefinitionVersionsClient) listAllHandleResponse(resp *http.Response) (DefinitionVersionsClientListAllResponse, error) { + result := DefinitionVersionsClientListAllResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListAllResponse{}, err + } + return result, nil +} + +// ListAllAtManagementGroup - 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 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup +// method. +func (client *DefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientListAllAtManagementGroupOptions) (DefinitionVersionsClientListAllAtManagementGroupResponse, error) { + var err error + req, err := client.listAllAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + resp, err := client.listAllAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// listAllAtManagementGroupCreateRequest creates the ListAllAtManagementGroup request. +func (client *DefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientListAllAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicyDefinitionVersions" + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllAtManagementGroupHandleResponse handles the ListAllAtManagementGroup response. +func (client *DefinitionVersionsClient) listAllAtManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientListAllAtManagementGroupResponse, error) { + result := DefinitionVersionsClientListAllAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + return result, nil +} + +// ListAllBuiltins - 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 +// - options - DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins +// method. +func (client *DefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *DefinitionVersionsClientListAllBuiltinsOptions) (DefinitionVersionsClientListAllBuiltinsResponse, error) { + var err error + req, err := client.listAllBuiltinsCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + resp, err := client.listAllBuiltinsHandleResponse(httpResp) + return resp, err +} + +// listAllBuiltinsCreateRequest creates the ListAllBuiltins request. +func (client *DefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context.Context, options *DefinitionVersionsClientListAllBuiltinsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/listPolicyDefinitionVersions" + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllBuiltinsHandleResponse handles the ListAllBuiltins response. +func (client *DefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http.Response) (DefinitionVersionsClientListAllBuiltinsResponse, error) { + result := DefinitionVersionsClientListAllBuiltinsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + return result, nil +} + +// 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 +// - options - DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager +// method. +func (client *DefinitionVersionsClient) NewListBuiltInPager(options *DefinitionVersionsClientListBuiltInOptions) *runtime.Pager[DefinitionVersionsClientListBuiltInResponse] { + return runtime.NewPager(runtime.PagingHandler[DefinitionVersionsClientListBuiltInResponse]{ + More: func(page DefinitionVersionsClientListBuiltInResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefinitionVersionsClientListBuiltInResponse) (DefinitionVersionsClientListBuiltInResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBuiltInCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DefinitionVersionsClientListBuiltInResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListBuiltInResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DefinitionVersionsClientListBuiltInResponse{}, runtime.NewResponseError(resp) + } + return client.listBuiltInHandleResponse(resp) + }, + }) +} + +// listBuiltInCreateRequest creates the ListBuiltIn request. +func (client *DefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Context, options *DefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + 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", "2023-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBuiltInHandleResponse handles the ListBuiltIn response. +func (client *DefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Response) (DefinitionVersionsClientListBuiltInResponse, error) { + result := DefinitionVersionsClientListBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListBuiltInResponse{}, err + } + return result, nil +} + +// 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 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager +// method. +func (client *DefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, options *DefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionVersionsClientListByManagementGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DefinitionVersionsClientListByManagementGroupResponse]{ + More: func(page DefinitionVersionsClientListByManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefinitionVersionsClientListByManagementGroupResponse) (DefinitionVersionsClientListByManagementGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByManagementGroupCreateRequest(ctx, managementGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DefinitionVersionsClientListByManagementGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListByManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DefinitionVersionsClientListByManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByManagementGroupHandleResponse(resp) + }, + }) +} + +// listByManagementGroupCreateRequest creates the ListByManagementGroup request. +func (client *DefinitionVersionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientListByManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + 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", "2023-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByManagementGroupHandleResponse handles the ListByManagementGroup response. +func (client *DefinitionVersionsClient) listByManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientListByManagementGroupResponse, error) { + result := DefinitionVersionsClientListByManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListByManagementGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go index 2570f46d050c..b54845ca0a7a 100644 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -29,7 +28,7 @@ type ExemptionsClient struct { } // NewExemptionsClient creates a new instance of ExemptionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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) { @@ -50,7 +49,7 @@ func NewExemptionsClient(subscriptionID string, credential azcore.TokenCredentia // resources in the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-07-01-preview +// 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}', @@ -61,18 +60,21 @@ func NewExemptionsClient(subscriptionID string, credential azcore.TokenCredentia // - 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 req, err := client.createOrUpdateCreateRequest(ctx, scope, policyExemptionName, parameters, options) if err != nil { return ExemptionsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExemptionsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ExemptionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ExemptionsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -88,10 +90,13 @@ func (client *ExemptionsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2022-07-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -108,7 +113,7 @@ func (client *ExemptionsClient) createOrUpdateHandleResponse(resp *http.Response // '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-07-01-preview +// 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}', @@ -117,16 +122,18 @@ func (client *ExemptionsClient) createOrUpdateHandleResponse(resp *http.Response // - 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 req, err := client.deleteCreateRequest(ctx, scope, policyExemptionName, options) if err != nil { return ExemptionsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExemptionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ExemptionsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ExemptionsClientDeleteResponse{}, err } return ExemptionsClientDeleteResponse{}, nil } @@ -144,7 +151,7 @@ func (client *ExemptionsClient) deleteCreateRequest(ctx context.Context, scope s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2022-07-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -153,7 +160,7 @@ func (client *ExemptionsClient) deleteCreateRequest(ctx context.Context, scope s // 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 2020-07-01-preview +// 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}', @@ -162,18 +169,21 @@ func (client *ExemptionsClient) deleteCreateRequest(ctx context.Context, scope s // - 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 req, err := client.getCreateRequest(ctx, scope, policyExemptionName, options) if err != nil { return ExemptionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExemptionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExemptionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExemptionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -189,7 +199,7 @@ func (client *ExemptionsClient) getCreateRequest(ctx context.Context, scope stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-07-01-preview") + reqQP.Set("api-version", "2022-07-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -211,7 +221,7 @@ func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (Exemptio // 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 2020-07-01-preview +// 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]{ @@ -244,16 +254,13 @@ func (client *ExemptionsClient) NewListPager(options *ExemptionsClientListOption // 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", "2020-07-01-preview") + 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 { @@ -279,7 +286,7 @@ func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (Exempti // policy exemptions that are assigned to the management group or the management // group's ancestors. // -// Generated from API version 2020-07-01-preview +// 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. @@ -323,7 +330,7 @@ func (client *ExemptionsClient) listForManagementGroupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-07-01-preview") + 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 { @@ -360,7 +367,7 @@ func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http. // both in the {resourceType} parameter, format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, {resourceType} // == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). // -// Generated from API version 2020-07-01-preview +// 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) @@ -400,9 +407,6 @@ func (client *ExemptionsClient) NewListForResourcePager(resourceGroupName string // 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") @@ -423,7 +427,7 @@ func (client *ExemptionsClient) listForResourceCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-07-01-preview") + 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 { @@ -450,7 +454,7 @@ func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Respons // 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 2020-07-01-preview +// 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. @@ -485,9 +489,6 @@ func (client *ExemptionsClient) NewListForResourceGroupPager(resourceGroupName s // 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") @@ -498,7 +499,7 @@ func (client *ExemptionsClient) listForResourceGroupCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-07-01-preview") + 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 { @@ -517,3 +518,64 @@ func (client *ExemptionsClient) listForResourceGroupHandleResponse(resp *http.Re } 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 + 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, options *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 c1d89fb815b0..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go +++ /dev/null @@ -1,432 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json -func ExampleExemptionsClient_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.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.1075056Z"); 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.1075056Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json -func ExampleExemptionsClient_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.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.1075056Z"); 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.1075056Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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.1075056Z"); 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.1075056Z"); 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.1075056Z"); 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.1075056Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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.1075056Z"); 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.1075056Z"); 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.1075056Z"); 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.1075056Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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.1075056Z"); 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.1075056Z"); 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.1075056Z"); 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.1075056Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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.1075056Z"); 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.1075056Z"); 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.1075056Z"); 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.1075056Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index 2c8a1271c0ee..d46bae383353 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -3,14 +3,14 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 github.com/stretchr/testify v1.7.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -21,9 +21,9 @@ require ( github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/resources/armpolicy/go.sum b/sdk/resourcemanager/resources/armpolicy/go.sum index b0f97586a165..592e81cc36bb 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.sum +++ b/sdk/resourcemanager/resources/armpolicy/go.sum @@ -1,9 +1,9 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= @@ -31,12 +31,12 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/sdk/resourcemanager/resources/armpolicy/models.go b/sdk/resourcemanager/resources/armpolicy/models.go index 4521305f6c63..be0b626b5bac 100644 --- a/sdk/resourcemanager/resources/armpolicy/models.go +++ b/sdk/resourcemanager/resources/armpolicy/models.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -120,121 +119,41 @@ type AssignmentProperties struct { // The policy's excluded scopes. NotScopes []*string + // The policy property value override. + Overrides []*Override + // The parameter values for the assigned policy rule. The keys are the parameter names. Parameters map[string]*ParameterValuesValue // The ID of the policy definition or policy set definition being assigned. PolicyDefinitionID *string + // The resource selector list to filter policies by resource properties. + ResourceSelectors []*ResourceSelector + // READ-ONLY; The scope for the policy assignment. Scope *string } +// AssignmentUpdate - The policy assignment for Patch request. type AssignmentUpdate struct { // The managed identity associated with the policy assignment. Identity *Identity // The location of the policy assignment. Only required when utilizing managed identity. Location *string -} - -// AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method. -type AssignmentsClientCreateByIDOptions struct { - // placeholder for future optional parameters -} - -// AssignmentsClientCreateOptions contains the optional parameters for the AssignmentsClient.Create method. -type AssignmentsClientCreateOptions struct { - // placeholder for future optional parameters -} - -// AssignmentsClientDeleteByIDOptions contains the optional parameters for the AssignmentsClient.DeleteByID method. -type AssignmentsClientDeleteByIDOptions struct { - // placeholder for future optional parameters -} - -// AssignmentsClientDeleteOptions contains the optional parameters for the AssignmentsClient.Delete method. -type AssignmentsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. -type AssignmentsClientGetByIDOptions struct { - // placeholder for future optional parameters -} - -// AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. -type AssignmentsClientGetOptions struct { - // placeholder for future optional parameters -} - -// AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager -// method. -type AssignmentsClientListForManagementGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId - // eq '{value}''. If $filter is not provided, no filtering is performed. If - // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that - // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, - // the returned list includes all policy assignments of the policy definition whose id is {value}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 -} - -// AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager -// method. -type AssignmentsClientListForResourceGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId - // eq '{value}''. If $filter is not provided, no filtering is performed. If - // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that - // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, - // the returned list includes all policy assignments of the policy definition whose id is {value}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 -} - -// AssignmentsClientListForResourceOptions contains the optional parameters for the AssignmentsClient.NewListForResourcePager -// method. -type AssignmentsClientListForResourceOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId - // eq '{value}''. If $filter is not provided, no filtering is performed. If - // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that - // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, - // the returned list includes all policy assignments of the policy definition whose id is {value}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 -} -// AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. -type AssignmentsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId - // eq '{value}''. If $filter is not provided, no filtering is performed. If - // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that - // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, - // the returned list includes all policy assignments of the policy definition whose id is {value}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 + // The policy assignment properties for Patch request. + Properties *AssignmentUpdateProperties } -// AssignmentsClientUpdateByIDOptions contains the optional parameters for the AssignmentsClient.UpdateByID method. -type AssignmentsClientUpdateByIDOptions struct { - // placeholder for future optional parameters -} +// AssignmentUpdateProperties - The policy assignment properties for Patch request. +type AssignmentUpdateProperties struct { + // The policy property value override. + Overrides []*Override -// AssignmentsClientUpdateOptions contains the optional parameters for the AssignmentsClient.Update method. -type AssignmentsClientUpdateOptions struct { - // placeholder for future optional parameters + // The resource selector list to filter policies by resource properties. + ResourceSelectors []*ResourceSelector } // DataEffect - The data effect definition. @@ -320,20 +239,6 @@ type DataPolicyManifestProperties struct { ResourceTypeAliases []*ResourceTypeAliases } -// 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 -} - // Definition - The policy definition. type Definition struct { // The policy definition properties. @@ -401,6 +306,12 @@ type DefinitionProperties struct { // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. PolicyType *PolicyType + + // The policy definition version in #.#.# format. + Version *string + + // A list of available versions for this policy definition. + Versions []*string } // DefinitionReference - The policy definition reference. @@ -418,85 +329,58 @@ type DefinitionReference struct { PolicyDefinitionReferenceID *string } -// DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup -// method. -type DefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} +// DefinitionVersion - The ID of the policy definition version. +type DefinitionVersion struct { + // The policy definition version properties. + Properties *DefinitionVersionProperties -// DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate method. -type DefinitionsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The ID of the policy definition version. + ID *string -// DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup -// method. -type DefinitionsClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The name of the policy definition version. + Name *string -// DefinitionsClientDeleteOptions contains the optional parameters for the DefinitionsClient.Delete method. -type DefinitionsClientDeleteOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData -// DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup -// method. -type DefinitionsClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters + // READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions/versions). + Type *string } -// DefinitionsClientGetBuiltInOptions contains the optional parameters for the DefinitionsClient.GetBuiltIn method. -type DefinitionsClientGetBuiltInOptions struct { - // placeholder for future optional parameters -} +// DefinitionVersionListResult - List of policy definition versions. +type DefinitionVersionListResult struct { + // The URL to use for getting the next set of results. + NextLink *string -// DefinitionsClientGetOptions contains the optional parameters for the DefinitionsClient.Get method. -type DefinitionsClientGetOptions struct { - // placeholder for future optional parameters + // An array of policy definitions versions. + Value []*DefinitionVersion } -// 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}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 -} +// DefinitionVersionProperties - The policy definition properties. +type DefinitionVersionProperties struct { + // The policy definition description. + Description *string -// DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager -// 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}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 -} + // The display name of the policy definition. + DisplayName *string + + // The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. + Metadata any + + // The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. + Mode *string + + // The parameter definitions for parameters used in the policy rule. The keys are the parameter names. + Parameters map[string]*ParameterDefinitionsValue -// 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}. - Filter *string - // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. - Top *int32 + // The policy rule. + PolicyRule any + + // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + PolicyType *PolicyType + + // The policy definition version in #.#.# format. + Version *string } // ErrorAdditionalInfo - The resource management error additional info. @@ -562,6 +446,9 @@ type ExemptionProperties struct { // 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 @@ -576,88 +463,24 @@ type ExemptionProperties struct { // 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 +} + +// ExemptionUpdate - The policy exemption for Patch request. +type ExemptionUpdate struct { + // The policy exemption properties for Patch request. + Properties *ExemptionUpdateProperties } -// 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 +// 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 + + // The resource selector list to filter policies by resource properties. + ResourceSelectors []*ResourceSelector } // Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity @@ -691,6 +514,18 @@ type NonComplianceMessage struct { PolicyDefinitionReferenceID *string } +// Override - The policy property value override. +type Override struct { + // The override kind. + Kind *OverrideKind + + // The list of the selector expressions. + Selectors []*Selector + + // The value to override the policy property. + Value *string +} + // ParameterDefinitionsValue - The definition of a parameter that can be provided to the policy. type ParameterDefinitionsValue struct { // The allowed values for the parameter. @@ -702,6 +537,11 @@ type ParameterDefinitionsValue struct { // General metadata for the parameter. Metadata *ParameterDefinitionsValueMetadata + // Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported + // for object-type parameters and follows the Json.NET Schema 2019-09 + // implementation. You can learn more about using schemas at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/. + Schema any + // The data type of the parameter. Type *ParameterType } @@ -733,6 +573,15 @@ type ParameterValuesValue struct { Value any } +// ResourceSelector - The resource selector to filter policies by resource properties. +type ResourceSelector struct { + // The name of the resource selector. + Name *string + + // The list of the selector expressions. + Selectors []*Selector +} + // ResourceTypeAliases - The resource type aliases definition. type ResourceTypeAliases struct { // The aliases for property names. @@ -742,9 +591,21 @@ type ResourceTypeAliases struct { ResourceType *string } +// Selector - The selector expression. +type Selector struct { + // The list of values to filter in. + In []*string + + // The selector kind. + Kind *SelectorKind + + // The list of values to filter out. + NotIn []*string +} + // SetDefinition - The policy set definition. type SetDefinition struct { - // The policy definition properties. + // The policy set definition properties. Properties *SetDefinitionProperties // READ-ONLY; The ID of the policy set definition. @@ -789,91 +650,68 @@ type SetDefinitionProperties struct { // The metadata describing groups of policy definition references within the policy set definition. PolicyDefinitionGroups []*DefinitionGroup - // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + // The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. PolicyType *PolicyType -} -// SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup -// method. -type SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} + // The policy set definition version in #.#.# format. + Version *string -// SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate -// method. -type SetDefinitionsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters + // A list of available versions for this policy set definition. + Versions []*string } -// SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup -// method. -type SetDefinitionsClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} +// SetDefinitionVersion - The policy set definition version. +type SetDefinitionVersion struct { + // The policy set definition version properties. + Properties *SetDefinitionVersionProperties -// SetDefinitionsClientDeleteOptions contains the optional parameters for the SetDefinitionsClient.Delete method. -type SetDefinitionsClientDeleteOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The ID of the policy set definition version. + ID *string -// SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup -// method. -type SetDefinitionsClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The name of the policy set definition version. + Name *string -// SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn method. -type SetDefinitionsClientGetBuiltInOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData -// SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method. -type SetDefinitionsClientGetOptions struct { - // placeholder for future optional parameters + // READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions/versions). + Type *string } -// SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager -// method. -type SetDefinitionsClientListBuiltInOptions 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 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 -} +// SetDefinitionVersionListResult - List of policy set definition versions. +type SetDefinitionVersionListResult struct { + // The URL to use for getting the next set of results. + NextLink *string -// SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager -// method. -type SetDefinitionsClientListByManagementGroupOptions 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 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 + // An array of policy set definition versions. + Value []*SetDefinitionVersion } -// SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method. -type SetDefinitionsClientListOptions 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 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 +// SetDefinitionVersionProperties - The policy set definition properties. +type SetDefinitionVersionProperties struct { + // REQUIRED; An array of policy definition references. + PolicyDefinitions []*DefinitionReference + + // The policy set definition description. + Description *string + + // The display name of the policy set definition. + DisplayName *string + + // The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. + Metadata any + + // The policy set definition parameters that can be used in policy definition references. + Parameters map[string]*ParameterDefinitionsValue + + // The metadata describing groups of policy definition references within the policy set definition. + PolicyDefinitionGroups []*DefinitionGroup + + // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + PolicyType *PolicyType + + // The policy set definition version in #.#.# format. + Version *string } // SystemData - Metadata pertaining to creation and last modification of the resource. @@ -904,3 +742,84 @@ type UserAssignedIdentitiesValue struct { // 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 + + // READ-ONLY; The type of the resource (Microsoft.Authorization/variables). + Type *string +} + +// VariableColumn - The variable column. +type VariableColumn struct { + // REQUIRED; The name of this policy variable column. + ColumnName *string +} + +// VariableListResult - List of variables. +type VariableListResult struct { + // An array of variables. + Value []*Variable + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// VariableProperties - The variable properties. +type VariableProperties struct { + // REQUIRED; Variable column definitions. + Columns []*VariableColumn +} + +// VariableValue - The variable value. +type VariableValue struct { + // REQUIRED; Properties for the variable value. + Properties *VariableValueProperties + + // 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 + + // READ-ONLY; The type of the resource (Microsoft.Authorization/variables/values). + Type *string +} + +// VariableValueColumnValue - The name value tuple for this variable value column. +type VariableValueColumnValue struct { + // REQUIRED; Column name for the variable value + ColumnName *string + + // REQUIRED; Column value for the variable value; this can be an integer, double, boolean, null or a string. + ColumnValue any +} + +// 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 +} + +// VariableValueProperties - The variable value properties. +type VariableValueProperties struct { + // REQUIRED; Variable value column value array. + Values []*VariableValueColumnValue +} diff --git a/sdk/resourcemanager/resources/armpolicy/models_serde.go b/sdk/resourcemanager/resources/armpolicy/models_serde.go index bd17767cc57a..77bef198fe16 100644 --- a/sdk/resourcemanager/resources/armpolicy/models_serde.go +++ b/sdk/resourcemanager/resources/armpolicy/models_serde.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -259,8 +258,10 @@ func (a AssignmentProperties) MarshalJSON() ([]byte, error) { populateAny(objectMap, "metadata", a.Metadata) populate(objectMap, "nonComplianceMessages", a.NonComplianceMessages) populate(objectMap, "notScopes", a.NotScopes) + populate(objectMap, "overrides", a.Overrides) populate(objectMap, "parameters", a.Parameters) populate(objectMap, "policyDefinitionId", a.PolicyDefinitionID) + populate(objectMap, "resourceSelectors", a.ResourceSelectors) populate(objectMap, "scope", a.Scope) return json.Marshal(objectMap) } @@ -292,12 +293,18 @@ func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { case "notScopes": err = unpopulate(val, "NotScopes", &a.NotScopes) delete(rawMsg, key) + case "overrides": + err = unpopulate(val, "Overrides", &a.Overrides) + delete(rawMsg, key) case "parameters": err = unpopulate(val, "Parameters", &a.Parameters) delete(rawMsg, key) case "policyDefinitionId": err = unpopulate(val, "PolicyDefinitionID", &a.PolicyDefinitionID) delete(rawMsg, key) + case "resourceSelectors": + err = unpopulate(val, "ResourceSelectors", &a.ResourceSelectors) + delete(rawMsg, key) case "scope": err = unpopulate(val, "Scope", &a.Scope) delete(rawMsg, key) @@ -314,6 +321,7 @@ func (a AssignmentUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "identity", a.Identity) populate(objectMap, "location", a.Location) + populate(objectMap, "properties", a.Properties) return json.Marshal(objectMap) } @@ -332,6 +340,40 @@ func (a *AssignmentUpdate) UnmarshalJSON(data []byte) error { case "location": err = unpopulate(val, "Location", &a.Location) delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + 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 AssignmentUpdateProperties. +func (a AssignmentUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "overrides", a.Overrides) + populate(objectMap, "resourceSelectors", a.ResourceSelectors) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentUpdateProperties. +func (a *AssignmentUpdateProperties) 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 "overrides": + err = unpopulate(val, "Overrides", &a.Overrides) + delete(rawMsg, key) + case "resourceSelectors": + err = unpopulate(val, "ResourceSelectors", &a.ResourceSelectors) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -689,6 +731,8 @@ func (d DefinitionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "parameters", d.Parameters) populateAny(objectMap, "policyRule", d.PolicyRule) populate(objectMap, "policyType", d.PolicyType) + populate(objectMap, "version", d.Version) + populate(objectMap, "versions", d.Versions) return json.Marshal(objectMap) } @@ -722,6 +766,12 @@ func (d *DefinitionProperties) UnmarshalJSON(data []byte) error { case "policyType": err = unpopulate(val, "PolicyType", &d.PolicyType) delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) + case "versions": + err = unpopulate(val, "Versions", &d.Versions) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -769,6 +819,135 @@ func (d *DefinitionReference) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersion. +func (d DefinitionVersion) 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, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersion. +func (d *DefinitionVersion) 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 "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + 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 DefinitionVersionListResult. +func (d DefinitionVersionListResult) 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 DefinitionVersionListResult. +func (d *DefinitionVersionListResult) 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 DefinitionVersionProperties. +func (d DefinitionVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", d.Description) + populate(objectMap, "displayName", d.DisplayName) + 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 ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -920,6 +1099,7 @@ func (e *ExemptionListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExemptionProperties. func (e ExemptionProperties) 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) @@ -927,6 +1107,7 @@ func (e ExemptionProperties) MarshalJSON() ([]byte, error) { populateAny(objectMap, "metadata", e.Metadata) populate(objectMap, "policyAssignmentId", e.PolicyAssignmentID) populate(objectMap, "policyDefinitionReferenceIds", e.PolicyDefinitionReferenceIDs) + populate(objectMap, "resourceSelectors", e.ResourceSelectors) return json.Marshal(objectMap) } @@ -939,6 +1120,9 @@ 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) delete(rawMsg, key) @@ -960,6 +1144,67 @@ func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { case "policyDefinitionReferenceIds": err = unpopulate(val, "PolicyDefinitionReferenceIDs", &e.PolicyDefinitionReferenceIDs) delete(rawMsg, key) + case "resourceSelectors": + err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + 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 ExemptionUpdate. +func (e ExemptionUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdate. +func (e *ExemptionUpdate) 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 "properties": + err = unpopulate(val, "Properties", &e.Properties) + 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 ExemptionUpdateProperties. +func (e ExemptionUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) + populate(objectMap, "resourceSelectors", e.ResourceSelectors) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdateProperties. +func (e *ExemptionUpdateProperties) 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 "assignmentScopeValidation": + err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) + delete(rawMsg, key) + case "resourceSelectors": + err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1038,12 +1283,48 @@ func (n *NonComplianceMessage) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Override. +func (o Override) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", o.Kind) + populate(objectMap, "selectors", o.Selectors) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Override. +func (o *Override) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &o.Kind) + delete(rawMsg, key) + case "selectors": + err = unpopulate(val, "Selectors", &o.Selectors) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValue. func (p ParameterDefinitionsValue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "allowedValues", p.AllowedValues) populateAny(objectMap, "defaultValue", p.DefaultValue) populate(objectMap, "metadata", p.Metadata) + populateAny(objectMap, "schema", p.Schema) populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } @@ -1066,6 +1347,9 @@ func (p *ParameterDefinitionsValue) UnmarshalJSON(data []byte) error { case "metadata": err = unpopulate(val, "Metadata", &p.Metadata) delete(rawMsg, key) + case "schema": + err = unpopulate(val, "Schema", &p.Schema) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) @@ -1158,6 +1442,37 @@ func (p *ParameterValuesValue) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ResourceSelector. +func (r ResourceSelector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "selectors", r.Selectors) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceSelector. +func (r *ResourceSelector) 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 "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "selectors": + err = unpopulate(val, "Selectors", &r.Selectors) + 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 ResourceTypeAliases. func (r ResourceTypeAliases) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1189,6 +1504,41 @@ func (r *ResourceTypeAliases) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Selector. +func (s Selector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "in", s.In) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "notIn", s.NotIn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Selector. +func (s *Selector) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "in": + err = unpopulate(val, "In", &s.In) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "notIn": + err = unpopulate(val, "NotIn", &s.NotIn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SetDefinition. func (s SetDefinition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1273,6 +1623,8 @@ func (s SetDefinitionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "policyDefinitionGroups", s.PolicyDefinitionGroups) populate(objectMap, "policyDefinitions", s.PolicyDefinitions) populate(objectMap, "policyType", s.PolicyType) + populate(objectMap, "version", s.Version) + populate(objectMap, "versions", s.Versions) return json.Marshal(objectMap) } @@ -1306,7 +1658,142 @@ func (s *SetDefinitionProperties) UnmarshalJSON(data []byte) error { case "policyType": err = unpopulate(val, "PolicyType", &s.PolicyType) delete(rawMsg, key) - } + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + case "versions": + err = unpopulate(val, "Versions", &s.Versions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersion. +func (s SetDefinitionVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersion. +func (s *SetDefinitionVersion) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersionListResult. +func (s SetDefinitionVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersionListResult. +func (s *SetDefinitionVersionListResult) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersionProperties. +func (s SetDefinitionVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + populate(objectMap, "displayName", s.DisplayName) + populateAny(objectMap, "metadata", s.Metadata) + populate(objectMap, "parameters", s.Parameters) + populate(objectMap, "policyDefinitionGroups", s.PolicyDefinitionGroups) + populate(objectMap, "policyDefinitions", s.PolicyDefinitions) + populate(objectMap, "policyType", s.PolicyType) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersionProperties. +func (s *SetDefinitionVersionProperties) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &s.Metadata) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &s.Parameters) + delete(rawMsg, key) + case "policyDefinitionGroups": + err = unpopulate(val, "PolicyDefinitionGroups", &s.PolicyDefinitionGroups) + delete(rawMsg, key) + case "policyDefinitions": + err = unpopulate(val, "PolicyDefinitions", &s.PolicyDefinitions) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &s.PolicyType) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } @@ -1392,6 +1879,266 @@ func (u *UserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Variable. +func (v Variable) 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 Variable. +func (v *Variable) 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) + 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) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + 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) + 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 VariableListResult. +func (v VariableListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VariableListResult. +func (v *VariableListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + 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 VariableProperties. +func (v VariableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "columns", v.Columns) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VariableProperties. +func (v *VariableProperties) 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 "columns": + err = unpopulate(val, "Columns", &v.Columns) + 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) + 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) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + 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) + delete(rawMsg, key) + case "columnValue": + err = unpopulate(val, "ColumnValue", &v.ColumnValue) + 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 VariableValueListResult. +func (v VariableValueListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueListResult. +func (v *VariableValueListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + 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) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return diff --git a/sdk/resourcemanager/resources/armpolicy/options.go b/sdk/resourcemanager/resources/armpolicy/options.go new file mode 100644 index 000000000000..8ebd82190ccf --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/options.go @@ -0,0 +1,628 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpolicy + +// AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method. +type AssignmentsClientCreateByIDOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientCreateOptions contains the optional parameters for the AssignmentsClient.Create method. +type AssignmentsClientCreateOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientDeleteByIDOptions contains the optional parameters for the AssignmentsClient.DeleteByID method. +type AssignmentsClientDeleteByIDOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientDeleteOptions contains the optional parameters for the AssignmentsClient.Delete method. +type AssignmentsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. +type AssignmentsClientGetByIDOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. +type AssignmentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager +// method. +type AssignmentsClientListForManagementGroupOptions struct { + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId + // eq '{value}''. If $filter is not provided, no filtering is performed. If + // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is + // everything in the unfiltered list except those applied to sub scopes contained + // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that + // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, + // the returned list includes all policy assignments of the policy definition whose id is {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager +// method. +type AssignmentsClientListForResourceGroupOptions struct { + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId + // eq '{value}''. If $filter is not provided, no filtering is performed. If + // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is + // everything in the unfiltered list except those applied to sub scopes contained + // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that + // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, + // the returned list includes all policy assignments of the policy definition whose id is {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// AssignmentsClientListForResourceOptions contains the optional parameters for the AssignmentsClient.NewListForResourcePager +// method. +type AssignmentsClientListForResourceOptions struct { + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId + // eq '{value}''. If $filter is not provided, no filtering is performed. If + // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is + // everything in the unfiltered list except those applied to sub scopes contained + // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that + // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, + // the returned list includes all policy assignments of the policy definition whose id is {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. +type AssignmentsClientListOptions struct { + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId + // eq '{value}''. If $filter is not provided, no filtering is performed. If + // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is + // everything in the unfiltered list except those applied to sub scopes contained + // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that + // at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, + // the returned list includes all policy assignments of the policy definition whose id is {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// AssignmentsClientUpdateByIDOptions contains the optional parameters for the AssignmentsClient.UpdateByID method. +type AssignmentsClientUpdateByIDOptions struct { + // placeholder for future optional parameters +} + +// AssignmentsClientUpdateOptions contains the optional parameters for the AssignmentsClient.Update method. +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 { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate +// method. +type DefinitionVersionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup +// method. +type DefinitionVersionsClientDeleteAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete method. +type DefinitionVersionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup +// method. +type DefinitionVersionsClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn +// method. +type DefinitionVersionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method. +type DefinitionVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup +// method. +type DefinitionVersionsClientListAllAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins +// method. +type DefinitionVersionsClientListAllBuiltinsOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll method. +type DefinitionVersionsClientListAllOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager +// method. +type DefinitionVersionsClientListBuiltInOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager +// method. +type DefinitionVersionsClientListByManagementGroupOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager method. +type DefinitionVersionsClientListOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup +// method. +type DefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate method. +type DefinitionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup +// method. +type DefinitionsClientDeleteAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionsClientDeleteOptions contains the optional parameters for the DefinitionsClient.Delete method. +type DefinitionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup +// method. +type DefinitionsClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionsClientGetBuiltInOptions contains the optional parameters for the DefinitionsClient.GetBuiltIn method. +type DefinitionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + +// DefinitionsClientGetOptions contains the optional parameters for the DefinitionsClient.Get method. +type DefinitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// 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}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager +// method. +type DefinitionsClientListByManagementGroupOptions struct { + // The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category + // eq '{value}''. If $filter is not provided, no filtering is performed. If + // $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If + // $filter='policyType -eq {value}' is provided, the returned list only includes all + // policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. + // If $filter='category -eq {value}' is provided, the returned list only + // includes all policy definitions whose category match the {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// 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}. + 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 { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate +// method. +type SetDefinitionVersionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup +// method. +type SetDefinitionVersionsClientDeleteAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete method. +type SetDefinitionVersionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup +// method. +type SetDefinitionVersionsClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn +// method. +type SetDefinitionVersionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get method. +type SetDefinitionVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup +// method. +type SetDefinitionVersionsClientListAllAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins +// method. +type SetDefinitionVersionsClientListAllBuiltinsOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll +// method. +type SetDefinitionVersionsClientListAllOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager +// method. +type SetDefinitionVersionsClientListBuiltInOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager +// method. +type SetDefinitionVersionsClientListByManagementGroupOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager +// method. +type SetDefinitionVersionsClientListOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup +// method. +type SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate +// method. +type SetDefinitionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup +// method. +type SetDefinitionsClientDeleteAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientDeleteOptions contains the optional parameters for the SetDefinitionsClient.Delete method. +type SetDefinitionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup +// method. +type SetDefinitionsClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn method. +type SetDefinitionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method. +type SetDefinitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager +// method. +type SetDefinitionsClientListBuiltInOptions 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 set definitions that at the given scope. + // If $filter='policyType -eq {value}' is provided, the returned list only includes + // all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, + // and Static. If $filter='category -eq {value}' is provided, the returned list only + // includes all policy set definitions whose category match the {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager +// method. +type SetDefinitionsClientListByManagementGroupOptions 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 set definitions that at the given scope. + // If $filter='policyType -eq {value}' is provided, the returned list only includes + // all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, + // and Static. If $filter='category -eq {value}' is provided, the returned list only + // includes all policy set definitions whose category match the {value}. + Filter *string + + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method. +type SetDefinitionsClientListOptions 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 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 +// method. +type VariablesClientListForManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. +type VariablesClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/resources/armpolicy/response_types.go b/sdk/resourcemanager/resources/armpolicy/response_types.go index 21d3c08cb86c..6c5262aabdcc 100644 --- a/sdk/resourcemanager/resources/armpolicy/response_types.go +++ b/sdk/resourcemanager/resources/armpolicy/response_types.go @@ -3,89 +3,180 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy // AssignmentsClientCreateByIDResponse contains the response from method AssignmentsClient.CreateByID. type AssignmentsClientCreateByIDResponse struct { + // The policy assignment. Assignment } // AssignmentsClientCreateResponse contains the response from method AssignmentsClient.Create. type AssignmentsClientCreateResponse struct { + // The policy assignment. Assignment } // AssignmentsClientDeleteByIDResponse contains the response from method AssignmentsClient.DeleteByID. type AssignmentsClientDeleteByIDResponse struct { + // The policy assignment. Assignment } // AssignmentsClientDeleteResponse contains the response from method AssignmentsClient.Delete. type AssignmentsClientDeleteResponse struct { + // The policy assignment. Assignment } // AssignmentsClientGetByIDResponse contains the response from method AssignmentsClient.GetByID. type AssignmentsClientGetByIDResponse struct { + // The policy assignment. Assignment } // AssignmentsClientGetResponse contains the response from method AssignmentsClient.Get. type AssignmentsClientGetResponse struct { + // The policy assignment. Assignment } // AssignmentsClientListForManagementGroupResponse contains the response from method AssignmentsClient.NewListForManagementGroupPager. type AssignmentsClientListForManagementGroupResponse struct { + // List of policy assignments. AssignmentListResult } // AssignmentsClientListForResourceGroupResponse contains the response from method AssignmentsClient.NewListForResourceGroupPager. type AssignmentsClientListForResourceGroupResponse struct { + // List of policy assignments. AssignmentListResult } // AssignmentsClientListForResourceResponse contains the response from method AssignmentsClient.NewListForResourcePager. type AssignmentsClientListForResourceResponse struct { + // List of policy assignments. AssignmentListResult } // AssignmentsClientListResponse contains the response from method AssignmentsClient.NewListPager. type AssignmentsClientListResponse struct { + // List of policy assignments. AssignmentListResult } // AssignmentsClientUpdateByIDResponse contains the response from method AssignmentsClient.UpdateByID. type AssignmentsClientUpdateByIDResponse struct { + // The policy assignment. Assignment } // AssignmentsClientUpdateResponse contains the response from method AssignmentsClient.Update. type AssignmentsClientUpdateResponse struct { + // The policy assignment. 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. + DefinitionVersion +} + +// DefinitionVersionsClientCreateOrUpdateResponse contains the response from method DefinitionVersionsClient.CreateOrUpdate. +type DefinitionVersionsClientCreateOrUpdateResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientDeleteAtManagementGroupResponse contains the response from method DefinitionVersionsClient.DeleteAtManagementGroup. +type DefinitionVersionsClientDeleteAtManagementGroupResponse struct { + // placeholder for future response values +} + +// DefinitionVersionsClientDeleteResponse contains the response from method DefinitionVersionsClient.Delete. +type DefinitionVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// DefinitionVersionsClientGetAtManagementGroupResponse contains the response from method DefinitionVersionsClient.GetAtManagementGroup. +type DefinitionVersionsClientGetAtManagementGroupResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientGetBuiltInResponse contains the response from method DefinitionVersionsClient.GetBuiltIn. +type DefinitionVersionsClientGetBuiltInResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientGetResponse contains the response from method DefinitionVersionsClient.Get. +type DefinitionVersionsClientGetResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method DefinitionVersionsClient.ListAllAtManagementGroup. +type DefinitionVersionsClientListAllAtManagementGroupResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListAllBuiltinsResponse contains the response from method DefinitionVersionsClient.ListAllBuiltins. +type DefinitionVersionsClientListAllBuiltinsResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListAllResponse contains the response from method DefinitionVersionsClient.ListAll. +type DefinitionVersionsClientListAllResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListBuiltInResponse contains the response from method DefinitionVersionsClient.NewListBuiltInPager. +type DefinitionVersionsClientListBuiltInResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListByManagementGroupResponse contains the response from method DefinitionVersionsClient.NewListByManagementGroupPager. +type DefinitionVersionsClientListByManagementGroupResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListResponse contains the response from method DefinitionVersionsClient.NewListPager. +type DefinitionVersionsClientListResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + // DefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionsClient.CreateOrUpdateAtManagementGroup. type DefinitionsClientCreateOrUpdateAtManagementGroupResponse struct { + // The policy definition. Definition } // DefinitionsClientCreateOrUpdateResponse contains the response from method DefinitionsClient.CreateOrUpdate. type DefinitionsClientCreateOrUpdateResponse struct { + // The policy definition. Definition } @@ -101,36 +192,43 @@ type DefinitionsClientDeleteResponse struct { // DefinitionsClientGetAtManagementGroupResponse contains the response from method DefinitionsClient.GetAtManagementGroup. type DefinitionsClientGetAtManagementGroupResponse struct { + // The policy definition. Definition } // DefinitionsClientGetBuiltInResponse contains the response from method DefinitionsClient.GetBuiltIn. type DefinitionsClientGetBuiltInResponse struct { + // The policy definition. Definition } // DefinitionsClientGetResponse contains the response from method DefinitionsClient.Get. type DefinitionsClientGetResponse struct { + // The policy definition. Definition } // DefinitionsClientListBuiltInResponse contains the response from method DefinitionsClient.NewListBuiltInPager. type DefinitionsClientListBuiltInResponse struct { + // List of policy definitions. DefinitionListResult } // DefinitionsClientListByManagementGroupResponse contains the response from method DefinitionsClient.NewListByManagementGroupPager. type DefinitionsClientListByManagementGroupResponse struct { + // List of policy definitions. DefinitionListResult } // DefinitionsClientListResponse contains the response from method DefinitionsClient.NewListPager. type DefinitionsClientListResponse struct { + // List of policy definitions. DefinitionListResult } // ExemptionsClientCreateOrUpdateResponse contains the response from method ExemptionsClient.CreateOrUpdate. type ExemptionsClientCreateOrUpdateResponse struct { + // The policy exemption. Exemption } @@ -141,36 +239,125 @@ type ExemptionsClientDeleteResponse struct { // 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. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientCreateOrUpdateResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdate. +type SetDefinitionVersionsClientCreateOrUpdateResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientDeleteAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.DeleteAtManagementGroup. +type SetDefinitionVersionsClientDeleteAtManagementGroupResponse struct { + // placeholder for future response values +} + +// SetDefinitionVersionsClientDeleteResponse contains the response from method SetDefinitionVersionsClient.Delete. +type SetDefinitionVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// SetDefinitionVersionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.GetAtManagementGroup. +type SetDefinitionVersionsClientGetAtManagementGroupResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientGetBuiltInResponse contains the response from method SetDefinitionVersionsClient.GetBuiltIn. +type SetDefinitionVersionsClientGetBuiltInResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientGetResponse contains the response from method SetDefinitionVersionsClient.Get. +type SetDefinitionVersionsClientGetResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.ListAllAtManagementGroup. +type SetDefinitionVersionsClientListAllAtManagementGroupResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListAllBuiltinsResponse contains the response from method SetDefinitionVersionsClient.ListAllBuiltins. +type SetDefinitionVersionsClientListAllBuiltinsResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListAllResponse contains the response from method SetDefinitionVersionsClient.ListAll. +type SetDefinitionVersionsClientListAllResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListBuiltInResponse contains the response from method SetDefinitionVersionsClient.NewListBuiltInPager. +type SetDefinitionVersionsClientListBuiltInResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListByManagementGroupResponse contains the response from method SetDefinitionVersionsClient.NewListByManagementGroupPager. +type SetDefinitionVersionsClientListByManagementGroupResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListResponse contains the response from method SetDefinitionVersionsClient.NewListPager. +type SetDefinitionVersionsClientListResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + // SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionsClient.CreateOrUpdateAtManagementGroup. type SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse struct { + // The policy set definition. SetDefinition } // SetDefinitionsClientCreateOrUpdateResponse contains the response from method SetDefinitionsClient.CreateOrUpdate. type SetDefinitionsClientCreateOrUpdateResponse struct { + // The policy set definition. SetDefinition } @@ -186,30 +373,128 @@ type SetDefinitionsClientDeleteResponse struct { // SetDefinitionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionsClient.GetAtManagementGroup. type SetDefinitionsClientGetAtManagementGroupResponse struct { + // The policy set definition. SetDefinition } // SetDefinitionsClientGetBuiltInResponse contains the response from method SetDefinitionsClient.GetBuiltIn. type SetDefinitionsClientGetBuiltInResponse struct { + // The policy set definition. SetDefinition } // SetDefinitionsClientGetResponse contains the response from method SetDefinitionsClient.Get. type SetDefinitionsClientGetResponse struct { + // The policy set definition. SetDefinition } // SetDefinitionsClientListBuiltInResponse contains the response from method SetDefinitionsClient.NewListBuiltInPager. type SetDefinitionsClientListBuiltInResponse struct { + // List of policy set definitions. SetDefinitionListResult } // SetDefinitionsClientListByManagementGroupResponse contains the response from method SetDefinitionsClient.NewListByManagementGroupPager. type SetDefinitionsClientListByManagementGroupResponse struct { + // List of policy set definitions. SetDefinitionListResult } // SetDefinitionsClientListResponse contains the response from method SetDefinitionsClient.NewListPager. type SetDefinitionsClientListResponse struct { + // List of policy set definitions. 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 +} + +// VariablesClientListResponse contains the response from method VariablesClient.NewListPager. +type VariablesClientListResponse struct { + // List of variables. + VariableListResult +} diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go index b2188f2387e4..3b599a5ffbcb 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy @@ -30,7 +29,7 @@ type SetDefinitionsClient struct { } // NewSetDefinitionsClient creates a new instance of SetDefinitionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionsClient, error) { @@ -48,46 +47,49 @@ 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 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to create. // - parameters - The policy set definition properties. // - options - SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate // method. func (client *SetDefinitionsClient) CreateOrUpdate(ctx context.Context, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateOptions) (SetDefinitionsClientCreateOrUpdateResponse, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, policySetDefinitionName, parameters, options) if err != nil { return SetDefinitionsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SetDefinitionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *SetDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if policySetDefinitionName == "" { return nil, errors.New("parameter policySetDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) - 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.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -103,47 +105,53 @@ 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 2021-06-01 -// - policySetDefinitionName - The name of the policy set definition to create. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policySetDefinitionName - The name of the policy set definition to create. // - parameters - The policy set definition properties. // - options - SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup // method. -func (client *SetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, policySetDefinitionName string, managementGroupID string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, policySetDefinitionName, managementGroupID, parameters, options) +func (client *SetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { + var err error + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, policySetDefinitionName, parameters, options) if err != nil { return SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } - return client.createOrUpdateAtManagementGroupHandleResponse(resp) + resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) + return resp, err } // createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policySetDefinitionName string, managementGroupID string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { +func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. @@ -158,20 +166,22 @@ 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 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to delete. // - 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 req, err := client.deleteCreateRequest(ctx, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return SetDefinitionsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientDeleteResponse{}, err } return SetDefinitionsClientDeleteResponse{}, nil } @@ -179,20 +189,17 @@ func (client *SetDefinitionsClient) Delete(ctx context.Context, policySetDefinit // deleteCreateRequest creates the Delete request. func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if policySetDefinitionName == "" { return nil, errors.New("parameter policySetDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) - 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.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -202,43 +209,45 @@ func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, pol // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policySetDefinitionName - The name of the policy set definition to delete. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policySetDefinitionName - The name of the policy set definition to delete. // - options - SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup // method. -func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (SetDefinitionsClientDeleteAtManagementGroupResponse, error) { - req, err := client.deleteAtManagementGroupCreateRequest(ctx, policySetDefinitionName, managementGroupID, options) +func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (SetDefinitionsClientDeleteAtManagementGroupResponse, error) { + var err error + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientDeleteAtManagementGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientDeleteAtManagementGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return SetDefinitionsClientDeleteAtManagementGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientDeleteAtManagementGroupResponse{}, err } return SetDefinitionsClientDeleteAtManagementGroupResponse{}, nil } // deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { +func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -247,41 +256,41 @@ func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx con // 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 2021-06-01 +// Generated from API version 2023-04-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) { + var err error req, err := client.getCreateRequest(ctx, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SetDefinitionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *SetDefinitionsClient) getCreateRequest(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if policySetDefinitionName == "" { return nil, errors.New("parameter policySetDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) - 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -300,43 +309,46 @@ func (client *SetDefinitionsClient) getHandleResponse(resp *http.Response) (SetD // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policySetDefinitionName - The name of the policy set definition to get. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup // method. -func (client *SetDefinitionsClient) GetAtManagementGroup(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientGetAtManagementGroupOptions) (SetDefinitionsClientGetAtManagementGroupResponse, error) { - req, err := client.getAtManagementGroupCreateRequest(ctx, policySetDefinitionName, managementGroupID, options) +func (client *SetDefinitionsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientGetAtManagementGroupOptions) (SetDefinitionsClientGetAtManagementGroupResponse, error) { + var err error + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientGetAtManagementGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientGetAtManagementGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SetDefinitionsClientGetAtManagementGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientGetAtManagementGroupResponse{}, err } - return client.getAtManagementGroupHandleResponse(resp) + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err } // getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { +func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -354,23 +366,26 @@ 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 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn // method. func (client *SetDefinitionsClient) GetBuiltIn(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientGetBuiltInOptions) (SetDefinitionsClientGetBuiltInResponse, error) { + var err error req, err := client.getBuiltInCreateRequest(ctx, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientGetBuiltInResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SetDefinitionsClientGetBuiltInResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SetDefinitionsClientGetBuiltInResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionsClientGetBuiltInResponse{}, err } - return client.getBuiltInHandleResponse(resp) + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err } // getBuiltInCreateRequest creates the GetBuiltIn request. @@ -385,7 +400,7 @@ func (client *SetDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -411,7 +426,7 @@ func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response // 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 2021-06-01 +// Generated from API version 2023-04-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]{ @@ -444,16 +459,13 @@ func (client *SetDefinitionsClient) NewListPager(options *SetDefinitionsClientLi // listCreateRequest creates the List request. func (client *SetDefinitionsClient) listCreateRequest(ctx context.Context, options *SetDefinitionsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" - 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", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } @@ -480,7 +492,7 @@ func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (Set // 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 2021-06-01 +// Generated from API version 2023-04-01 // - options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager // method. func (client *SetDefinitionsClient) NewListBuiltInPager(options *SetDefinitionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionsClientListBuiltInResponse] { @@ -519,7 +531,7 @@ func (client *SetDefinitionsClient) listBuiltInCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } @@ -553,7 +565,7 @@ func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Respons // 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 2021-06-01 +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. // - options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager // method. @@ -597,7 +609,7 @@ func (client *SetDefinitionsClient) listByManagementGroupCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go deleted file mode 100644 index fdfda46c6dc7..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go +++ /dev/null @@ -1,1028 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "namePrefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - DefaultValue: "myPrefix", - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - DisplayName: to.Ptr("Prefix to enforce on resource names"), - }, - }, - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "[parameters('namePrefix')]", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "namePrefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // DefaultValue: "myPrefix", - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Prefix to enforce on resource names"), - // }, - // }, - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "[parameters('namePrefix')]", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - { - Name: to.Ptr("CostSaving"), - Description: to.Ptr("Policies designed to control spend within a subscription."), - DisplayName: to.Ptr("Cost Management Policies"), - }, - { - Name: to.Ptr("Organizational"), - Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - DisplayName: to.Ptr("Organizational Policies"), - }}, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - GroupNames: []*string{ - to.Ptr("CostSaving")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - GroupNames: []*string{ - to.Ptr("Organizational")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.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{ - // { - // 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"), - // }, - // { - // 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"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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", 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{ - // { - // 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"), - // }, - // { - // 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"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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", 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{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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, - 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{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // 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", - // }, - // }, - // }, - // 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: "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"), - // }}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-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, - 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{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.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{ - // { - // 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"), - // }, - // { - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - { - Name: to.Ptr("CostSaving"), - Description: to.Ptr("Policies designed to control spend within a subscription."), - DisplayName: to.Ptr("Cost Management Policies"), - }, - { - Name: to.Ptr("Organizational"), - Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - DisplayName: to.Ptr("Organizational Policies"), - }}, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - GroupNames: []*string{ - to.Ptr("CostSaving")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - GroupNames: []*string{ - to.Ptr("Organizational")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // 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"), - // }, - // { - // 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"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionsClient().DeleteAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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, "CostManagement", "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.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{ - // { - // 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"), - // }, - // { - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/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", &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: 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{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // 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"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // 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{ - // { - // 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"), - // }, - // { - // 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"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go new file mode 100644 index 000000000000..1a0efb5ecce6 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go @@ -0,0 +1,792 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. 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" + "strconv" + "strings" +) + +// SetDefinitionVersionsClient contains the methods for the PolicySetDefinitionVersions group. +// Don't use this type directly, use NewSetDefinitionVersionsClient() instead. +type SetDefinitionVersionsClient struct { + internal *arm.Client + subscriptionID string + policySetDefinitionName string + policyDefinitionVersion string +} + +// NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - policySetDefinitionName - The name of the policy set 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 +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSetDefinitionVersionsClient(subscriptionID string, policySetDefinitionName string, policyDefinitionVersion string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionVersionsClient, error) { + cl, err := arm.NewClient(moduleName+".SetDefinitionVersionsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SetDefinitionVersionsClient{ + subscriptionID: subscriptionID, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - This operation creates or updates a policy set definition version in the given subscription with the given +// name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - parameters - The policy set definition properties. +// - options - SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate +// method. +func (client *SetDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, parameters, options) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SetDefinitionVersionsClient) createOrUpdateCreateRequest(ctx context.Context, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 *SetDefinitionVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (SetDefinitionVersionsClientCreateOrUpdateResponse, error) { + result := SetDefinitionVersionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// CreateOrUpdateAtManagementGroup - This operation creates or updates a policy set definition version in the given management +// group with the given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - parameters - The policy set definition version properties. +// - options - SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + var err error + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupName, parameters, options) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. +func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + result := SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + return result, nil +} + +// 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 +// - options - SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete +// method. +func (client *SetDefinitionVersionsClient) Delete(ctx context.Context, options *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientDeleteResponse{}, err + } + return SetDefinitionVersionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteAtManagementGroup - This operation deletes the policy set definition version in the given management group with the +// given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error) { + var err error + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, nil +} + +// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. +func (client *SetDefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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") + 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 +// - options - SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get +// method. +func (client *SetDefinitionVersionsClient) Get(ctx context.Context, options *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SetDefinitionVersionsClient) getCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SetDefinitionVersionsClient) getHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetResponse, error) { + result := SetDefinitionVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientGetResponse{}, err + } + return result, nil +} + +// GetAtManagementGroup - This operation retrieves the policy set definition version in the given management group with the +// given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error) { + var err error + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. +func (client *SetDefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. +func (client *SetDefinitionVersionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error) { + result := SetDefinitionVersionsClientGetAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + return result, nil +} + +// 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 +// - options - SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn +// method. +func (client *SetDefinitionVersionsClient) GetBuiltIn(ctx context.Context, options *SetDefinitionVersionsClientGetBuiltInOptions) (SetDefinitionVersionsClientGetBuiltInResponse, error) { + var err error + req, err := client.getBuiltInCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *SetDefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBuiltInHandleResponse handles the GetBuiltIn response. +func (client *SetDefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetBuiltInResponse, error) { + result := SetDefinitionVersionsClientGetBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + return result, nil +} + +// 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 +// - options - SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager +// method. +func (client *SetDefinitionVersionsClient) NewListPager(options *SetDefinitionVersionsClientListOptions) *runtime.Pager[SetDefinitionVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListResponse]{ + More: func(page SetDefinitionVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListResponse) (SetDefinitionVersionsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SetDefinitionVersionsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SetDefinitionVersionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *SetDefinitionVersionsClient) listCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + 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", "2023-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SetDefinitionVersionsClient) listHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListResponse, error) { + result := SetDefinitionVersionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListResponse{}, err + } + return result, nil +} + +// ListAll - 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 +// - options - SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll +// method. +func (client *SetDefinitionVersionsClient) ListAll(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error) { + var err error + req, err := client.listAllCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientListAllResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListAllResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientListAllResponse{}, err + } + resp, err := client.listAllHandleResponse(httpResp) + return resp, err +} + +// listAllCreateRequest creates the ListAll request. +func (client *SetDefinitionVersionsClient) listAllCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *SetDefinitionVersionsClient) listAllHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllResponse, error) { + result := SetDefinitionVersionsClientListAllResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListAllResponse{}, err + } + return result, nil +} + +// ListAllAtManagementGroup - 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 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error) { + var err error + req, err := client.listAllAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + resp, err := client.listAllAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// listAllAtManagementGroupCreateRequest creates the ListAllAtManagementGroup request. +func (client *SetDefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllAtManagementGroupHandleResponse handles the ListAllAtManagementGroup response. +func (client *SetDefinitionVersionsClient) listAllAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error) { + result := SetDefinitionVersionsClientListAllAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + return result, nil +} + +// ListAllBuiltins - 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 +// - options - SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins +// method. +func (client *SetDefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) { + var err error + req, err := client.listAllBuiltinsCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + resp, err := client.listAllBuiltinsHandleResponse(httpResp) + return resp, err +} + +// listAllBuiltinsCreateRequest creates the ListAllBuiltins request. +func (client *SetDefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" + 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", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllBuiltinsHandleResponse handles the ListAllBuiltins response. +func (client *SetDefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) { + result := SetDefinitionVersionsClientListAllBuiltinsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + return result, nil +} + +// 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 +// - options - SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager +// method. +func (client *SetDefinitionVersionsClient) NewListBuiltInPager(options *SetDefinitionVersionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionVersionsClientListBuiltInResponse] { + return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListBuiltInResponse]{ + More: func(page SetDefinitionVersionsClientListBuiltInResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListBuiltInResponse) (SetDefinitionVersionsClientListBuiltInResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBuiltInCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SetDefinitionVersionsClientListBuiltInResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListBuiltInResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SetDefinitionVersionsClientListBuiltInResponse{}, runtime.NewResponseError(resp) + } + return client.listBuiltInHandleResponse(resp) + }, + }) +} + +// listBuiltInCreateRequest creates the ListBuiltIn request. +func (client *SetDefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + 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", "2023-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBuiltInHandleResponse handles the ListBuiltIn response. +func (client *SetDefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListBuiltInResponse, error) { + result := SetDefinitionVersionsClientListBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListBuiltInResponse{}, err + } + return result, nil +} + +// 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 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager +// method. +func (client *SetDefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListByManagementGroupResponse]{ + More: func(page SetDefinitionVersionsClientListByManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListByManagementGroupResponse) (SetDefinitionVersionsClientListByManagementGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByManagementGroupCreateRequest(ctx, managementGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SetDefinitionVersionsClientListByManagementGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListByManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SetDefinitionVersionsClientListByManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByManagementGroupHandleResponse(resp) + }, + }) +} + +// listByManagementGroupCreateRequest creates the ListByManagementGroup request. +func (client *SetDefinitionVersionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + 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", "2023-04-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByManagementGroupHandleResponse handles the ListByManagementGroup response. +func (client *SetDefinitionVersionsClient) listByManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListByManagementGroupResponse, error) { + result := SetDefinitionVersionsClientListByManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListByManagementGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go index 6fe0d1514edd..fc0590d74830 100644 --- a/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armpolicy diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client.go b/sdk/resourcemanager/resources/armpolicy/variables_client.go new file mode 100644 index 000000000000..e706c101aab4 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/variables_client.go @@ -0,0 +1,484 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. 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+".VariablesClient", 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 + 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, options *VariablesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" + 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 + 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, options *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 + 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, options *VariablesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" + 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 + 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, options *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 + 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, options *VariablesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" + 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 + 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, options *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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VariablesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VariablesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariablesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *VariablesClient) listCreateRequest(ctx context.Context, options *VariablesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables" + 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VariablesClientListForManagementGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VariablesClientListForManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariablesClientListForManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listForManagementGroupHandleResponse(resp) + }, + }) +} + +// listForManagementGroupCreateRequest creates the ListForManagementGroup request. +func (client *VariablesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *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/variablevalues_client.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go new file mode 100644 index 000000000000..fa4879120fb2 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go @@ -0,0 +1,527 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. 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+".VariableValuesClient", 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 + 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, options *VariableValuesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" + 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 + 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, options *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 + 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, options *VariableValuesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" + 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 + 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, options *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 + 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, options *VariableValuesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" + 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 + 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, options *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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, variableName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VariableValuesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VariableValuesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariableValuesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *VariableValuesClient) listCreateRequest(ctx context.Context, variableName string, options *VariableValuesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values" + 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listForManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VariableValuesClientListForManagementGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VariableValuesClientListForManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariableValuesClientListForManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listForManagementGroupHandleResponse(resp) + }, + }) +} + +// listForManagementGroupCreateRequest creates the ListForManagementGroup request. +func (client *VariableValuesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, options *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 +}