From eec6fbd7a0e7ae6e63fac8fdf92f587f0629b690 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Oct 2022 03:51:27 +0000 Subject: [PATCH] CodeGen from PR 20921 in Azure/azure-rest-api-specs Introduce Microsoft.Resources/snapshots (#20921) * Add new snapshots type * Readme * Readme typo * suppressions * readme * Preview * Make augmented properties siblings of the original ARM resource * Snapshot * prettier * fix examples * comments * comments * comments --- .../resources/armpolicy/CHANGELOG.md | 69 + ...nments_client.go => assignments_client.go} | 5 +- .../resources/armpolicy/autorest.md | 6 +- ...zz_generated_constants.go => constants.go} | 3 +- ...lient.go => datapolicymanifests_client.go} | 2 +- ...itions_client.go => definitions_client.go} | 4 +- ...mptions_client.go => exemptions_client.go} | 5 +- .../resources/armpolicy/go.mod | 2 +- .../{zz_generated_models.go => models.go} | 178 +- .../resources/armpolicy/models_serde.go | 1673 +++++++++++++++++ ...ed_response_types.go => response_types.go} | 81 + ...ons_client.go => setdefinitions_client.go} | 4 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 1 + .../resources/armpolicy/variables_client.go | 478 +++++ .../armpolicy/variablevalues_client.go | 521 +++++ ...example_datapolicymanifests_client_test.go | 62 - ...d_example_policyassignments_client_test.go | 243 --- ...d_example_policydefinitions_client_test.go | 313 --- ...ed_example_policyexemptions_client_test.go | 198 -- ...xample_policysetdefinitions_client_test.go | 320 ---- .../armpolicy/zz_generated_models_serde.go | 267 --- 21 files changed, 3005 insertions(+), 1430 deletions(-) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_assignments_client.go => assignments_client.go} (99%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_constants.go => constants.go} (99%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_datapolicymanifests_client.go => datapolicymanifests_client.go} (99%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_definitions_client.go => definitions_client.go} (99%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_exemptions_client.go => exemptions_client.go} (99%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_models.go => models.go} (86%) create mode 100644 sdk/resourcemanager/resources/armpolicy/models_serde.go rename sdk/resourcemanager/resources/armpolicy/{zz_generated_response_types.go => response_types.go} (71%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_setdefinitions_client.go => setdefinitions_client.go} (99%) rename sdk/resourcemanager/resources/armpolicy/{zz_generated_time_rfc3339.go => time_rfc3339.go} (99%) create mode 100644 sdk/resourcemanager/resources/armpolicy/variables_client.go create mode 100644 sdk/resourcemanager/resources/armpolicy/variablevalues_client.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index e3414f76985d..1203593a78ca 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,74 @@ # Release History +## 0.7.0 (2022-10-05) +### Breaking Changes + +- Struct `CloudError` has been removed + +### Features Added + +- New function `NewVariablesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*VariablesClient, error)` +- New function `*VariablesClient.Delete(context.Context, string, *VariablesClientDeleteOptions) (VariablesClientDeleteResponse, error)` +- New function `*VariablesClient.CreateOrUpdate(context.Context, string, Variable, *VariablesClientCreateOrUpdateOptions) (VariablesClientCreateOrUpdateResponse, error)` +- New function `*VariablesClient.GetAtManagementGroup(context.Context, string, string, *VariablesClientGetAtManagementGroupOptions) (VariablesClientGetAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.NewListPager(string, *VariableValuesClientListOptions) *runtime.Pager[VariableValuesClientListResponse]` +- New function `*VariableValuesClient.NewListForManagementGroupPager(string, string, *VariableValuesClientListForManagementGroupOptions) *runtime.Pager[VariableValuesClientListForManagementGroupResponse]` +- New function `*VariableValuesClient.CreateOrUpdateAtManagementGroup(context.Context, string, string, string, VariableValue, *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*VariablesClient.NewListForManagementGroupPager(string, *VariablesClientListForManagementGroupOptions) *runtime.Pager[VariablesClientListForManagementGroupResponse]` +- New function `*VariablesClient.NewListPager(*VariablesClientListOptions) *runtime.Pager[VariablesClientListResponse]` +- New function `*VariablesClient.DeleteAtManagementGroup(context.Context, string, string, *VariablesClientDeleteAtManagementGroupOptions) (VariablesClientDeleteAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.DeleteAtManagementGroup(context.Context, string, string, string, *VariableValuesClientDeleteAtManagementGroupOptions) (VariableValuesClientDeleteAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.GetAtManagementGroup(context.Context, string, string, string, *VariableValuesClientGetAtManagementGroupOptions) (VariableValuesClientGetAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.Get(context.Context, string, string, *VariableValuesClientGetOptions) (VariableValuesClientGetResponse, error)` +- New function `*VariablesClient.Get(context.Context, string, *VariablesClientGetOptions) (VariablesClientGetResponse, error)` +- New function `NewVariableValuesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*VariableValuesClient, error)` +- New function `*VariablesClient.CreateOrUpdateAtManagementGroup(context.Context, string, string, Variable, *VariablesClientCreateOrUpdateAtManagementGroupOptions) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*VariableValuesClient.Delete(context.Context, string, string, *VariableValuesClientDeleteOptions) (VariableValuesClientDeleteResponse, error)` +- New function `*VariableValuesClient.CreateOrUpdate(context.Context, string, string, VariableValue, *VariableValuesClientCreateOrUpdateOptions) (VariableValuesClientCreateOrUpdateResponse, error)` +- 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 struct `VariableValuesClient` +- New struct `VariableValuesClientCreateOrUpdateAtManagementGroupOptions` +- New struct `VariableValuesClientCreateOrUpdateAtManagementGroupResponse` +- New struct `VariableValuesClientCreateOrUpdateOptions` +- New struct `VariableValuesClientCreateOrUpdateResponse` +- New struct `VariableValuesClientDeleteAtManagementGroupOptions` +- New struct `VariableValuesClientDeleteAtManagementGroupResponse` +- New struct `VariableValuesClientDeleteOptions` +- New struct `VariableValuesClientDeleteResponse` +- New struct `VariableValuesClientGetAtManagementGroupOptions` +- New struct `VariableValuesClientGetAtManagementGroupResponse` +- New struct `VariableValuesClientGetOptions` +- New struct `VariableValuesClientGetResponse` +- New struct `VariableValuesClientListForManagementGroupOptions` +- New struct `VariableValuesClientListForManagementGroupResponse` +- New struct `VariableValuesClientListOptions` +- New struct `VariableValuesClientListResponse` +- New struct `VariablesClient` +- New struct `VariablesClientCreateOrUpdateAtManagementGroupOptions` +- New struct `VariablesClientCreateOrUpdateAtManagementGroupResponse` +- New struct `VariablesClientCreateOrUpdateOptions` +- New struct `VariablesClientCreateOrUpdateResponse` +- New struct `VariablesClientDeleteAtManagementGroupOptions` +- New struct `VariablesClientDeleteAtManagementGroupResponse` +- New struct `VariablesClientDeleteOptions` +- New struct `VariablesClientDeleteResponse` +- New struct `VariablesClientGetAtManagementGroupOptions` +- New struct `VariablesClientGetAtManagementGroupResponse` +- New struct `VariablesClientGetOptions` +- New struct `VariablesClientGetResponse` +- New struct `VariablesClientListForManagementGroupOptions` +- New struct `VariablesClientListForManagementGroupResponse` +- New struct `VariablesClientListOptions` +- New struct `VariablesClientListResponse` + + ## 0.6.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.6.0, which contains breaking changes. diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go b/sdk/resourcemanager/resources/armpolicy/assignments_client.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go rename to sdk/resourcemanager/resources/armpolicy/assignments_client.go index 2625aa661631..0bcc1be0b243 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go +++ b/sdk/resourcemanager/resources/armpolicy/assignments_client.go @@ -5,6 +5,7 @@ // 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 @@ -381,7 +382,6 @@ func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (Ass // returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' // is provided, the returned list includes all policy assignments of the policy // definition whose id is {value}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.List method. func (client *AssignmentsClient) NewListPager(options *AssignmentsClientListOptions) *runtime.Pager[AssignmentsClientListResponse] { @@ -454,7 +454,6 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign // $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. // If $filter=policyDefinitionId eq '{value}' is provided, the returned list // includes all policy assignments of the policy definition whose id is {value} that apply to the management group. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // managementGroupID - The ID of the management group. // options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.ListForManagementGroup @@ -543,7 +542,6 @@ func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http // convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, // format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, // {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-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 @@ -641,7 +639,6 @@ func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Respon // the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' // is provided, the returned list includes all policy assignments of the // policy definition whose id is {value} that apply to the resource group. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // resourceGroupName - The name of the resource group that contains policy assignments. // options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.ListForResourceGroup diff --git a/sdk/resourcemanager/resources/armpolicy/autorest.md b/sdk/resourcemanager/resources/armpolicy/autorest.md index 8cb0bea8e30a..7154e0dac704 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.6.0 +module-version: 0.7.0 package-policy: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go b/sdk/resourcemanager/resources/armpolicy/constants.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go rename to sdk/resourcemanager/resources/armpolicy/constants.go index 909996d2c993..5b6927dd21bb 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armpolicy/constants.go @@ -5,12 +5,13 @@ // 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 const ( moduleName = "armpolicy" - moduleVersion = "v0.6.0" + moduleVersion = "v0.7.0" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to. diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go rename to sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go index fae9d662fa99..50e220817fdc 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go +++ b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go @@ -5,6 +5,7 @@ // 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 @@ -104,7 +105,6 @@ func (client *DataPolicyManifestsClient) getByPolicyModeHandleResponse(resp *htt // unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned // list only includes all data policy manifests that have a namespace matching // the provided value. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2020-09-01 // options - DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.List // method. diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go b/sdk/resourcemanager/resources/armpolicy/definitions_client.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go rename to sdk/resourcemanager/resources/armpolicy/definitions_client.go index 0a9edaab1126..1fafc67beff7 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitions_client.go @@ -5,6 +5,7 @@ // 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 @@ -409,7 +410,6 @@ func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) ( // 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}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // options - DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.List method. func (client *DefinitionsClient) NewListPager(options *DefinitionsClientListOptions) *runtime.Pager[DefinitionsClientListResponse] { @@ -480,7 +480,6 @@ func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (Defini // built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, // and Static. If $filter='category -eq {value}' is provided, the returned list // only includes all built-in policy definitions whose category match the {value}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.ListBuiltIn method. func (client *DefinitionsClient) NewListBuiltInPager(options *DefinitionsClientListBuiltInOptions) *runtime.Pager[DefinitionsClientListBuiltInResponse] { @@ -552,7 +551,6 @@ func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) // {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}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // managementGroupID - The ID of the management group. // options - DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.ListByManagementGroup diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go rename to sdk/resourcemanager/resources/armpolicy/exemptions_client.go index 6398c181f58d..c782c8950d26 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go @@ -5,6 +5,7 @@ // 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 @@ -217,7 +218,6 @@ func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (Exemptio // exemptions associated with the subscription, including those that apply // directly or from management groups that contain the given subscription, as well as any applied to objects contained within // the subscription. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2020-07-01-preview // options - ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.List method. func (client *ExemptionsClient) NewListPager(options *ExemptionsClientListOptions) *runtime.Pager[ExemptionsClientListResponse] { @@ -285,7 +285,6 @@ func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (Exempti // 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter=atScope() is provided, the returned list includes all // policy exemptions that are assigned to the management group or the management // group's ancestors. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2020-07-01-preview // managementGroupID - The ID of the management group. // options - ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.ListForManagementGroup @@ -366,7 +365,6 @@ func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http. // alternative to providing the namespace and type name separately is to provide // both in the {resourceType} parameter, format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, {resourceType} // == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2020-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 @@ -456,7 +454,6 @@ func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Respons // unfiltered list includes all policy exemptions associated with the resource // group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained // within the resource group. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2020-07-01-preview // resourceGroupName - The name of the resource group containing the resource. // options - ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.ListForResourceGroup diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index edc678271f0b..5f26fa389ba1 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -4,12 +4,12 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.0.0 github.com/stretchr/testify v1.7.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.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.4.0 // indirect diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_models.go b/sdk/resourcemanager/resources/armpolicy/models.go similarity index 86% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_models.go rename to sdk/resourcemanager/resources/armpolicy/models.go index e80f5c9b341b..ef67cf14f105 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_models.go +++ b/sdk/resourcemanager/resources/armpolicy/models.go @@ -5,6 +5,7 @@ // 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 @@ -235,13 +236,6 @@ type AssignmentsClientUpdateOptions struct { // placeholder for future optional parameters } -// CloudError - An error response from a policy operation. -type CloudError struct { - // Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows - // the OData error response format.) - Error *ErrorResponse `json:"error,omitempty"` -} - // DataEffect - The data effect definition. type DataEffect struct { // The data effect details schema. @@ -907,3 +901,173 @@ type UserAssignedIdentitiesValue struct { // READ-ONLY; The principal id of user assigned identity. PrincipalID *string `json:"principalId,omitempty" azure:"ro"` } + +// Variable - The variable. +type Variable struct { + // REQUIRED; Properties for the variable. + Properties *VariableProperties `json:"properties,omitempty"` + + // READ-ONLY; The ID of the variable. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the variable. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource (Microsoft.Authorization/variables). + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VariableColumn - The variable column. +type VariableColumn struct { + // REQUIRED; The name of this policy variable column. + ColumnName *string `json:"columnName,omitempty"` +} + +// VariableListResult - List of variables. +type VariableListResult struct { + // An array of variables. + Value []*Variable `json:"value,omitempty"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// VariableProperties - The variable properties. +type VariableProperties struct { + // REQUIRED; Variable column definitions. + Columns []*VariableColumn `json:"columns,omitempty"` +} + +// VariableValue - The variable value. +type VariableValue struct { + // REQUIRED; Properties for the variable value. + Properties *VariableValueProperties `json:"properties,omitempty"` + + // READ-ONLY; The ID of the variable. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the variable. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource (Microsoft.Authorization/variables/values). + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VariableValueColumnValue - The name value tuple for this variable value column. +type VariableValueColumnValue struct { + // REQUIRED; Column name for the variable value + ColumnName *string `json:"columnName,omitempty"` + + // REQUIRED; Column value for the variable value; this can be an integer, double, boolean, null or a string. + ColumnValue interface{} `json:"columnValue,omitempty"` +} + +// VariableValueListResult - List of variable values. +type VariableValueListResult struct { + // An array of variable values. + Value []*VariableValue `json:"value,omitempty"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// VariableValueProperties - The variable value properties. +type VariableValueProperties struct { + // REQUIRED; Variable value column value array. + Values []*VariableValueColumnValue `json:"values,omitempty"` +} + +// 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.ListForManagementGroup +// method. +type VariableValuesClientListForManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.List 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.ListForManagementGroup +// method. +type VariablesClientListForManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// VariablesClientListOptions contains the optional parameters for the VariablesClient.List method. +type VariablesClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/resources/armpolicy/models_serde.go b/sdk/resourcemanager/resources/armpolicy/models_serde.go new file mode 100644 index 000000000000..1ba65930758b --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/models_serde.go @@ -0,0 +1,1673 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Alias. +func (a Alias) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "defaultMetadata", a.DefaultMetadata) + populate(objectMap, "defaultPath", a.DefaultPath) + populate(objectMap, "defaultPattern", a.DefaultPattern) + populate(objectMap, "name", a.Name) + populate(objectMap, "paths", a.Paths) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Alias. +func (a *Alias) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "defaultMetadata": + err = unpopulate(val, "DefaultMetadata", &a.DefaultMetadata) + delete(rawMsg, key) + case "defaultPath": + err = unpopulate(val, "DefaultPath", &a.DefaultPath) + delete(rawMsg, key) + case "defaultPattern": + err = unpopulate(val, "DefaultPattern", &a.DefaultPattern) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "paths": + err = unpopulate(val, "Paths", &a.Paths) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AliasPath. +func (a AliasPath) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiVersions", a.APIVersions) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "path", a.Path) + populate(objectMap, "pattern", a.Pattern) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPath. +func (a *AliasPath) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiVersions": + err = unpopulate(val, "APIVersions", &a.APIVersions) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &a.Path) + delete(rawMsg, key) + case "pattern": + err = unpopulate(val, "Pattern", &a.Pattern) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AliasPathMetadata. +func (a AliasPathMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "attributes", a.Attributes) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPathMetadata. +func (a *AliasPathMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "attributes": + err = unpopulate(val, "Attributes", &a.Attributes) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AliasPattern. +func (a AliasPattern) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "phrase", a.Phrase) + populate(objectMap, "type", a.Type) + populate(objectMap, "variable", a.Variable) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPattern. +func (a *AliasPattern) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "phrase": + err = unpopulate(val, "Phrase", &a.Phrase) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "variable": + err = unpopulate(val, "Variable", &a.Variable) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Assignment. +func (a Assignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Assignment. +func (a *Assignment) 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 "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &a.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentListResult. +func (a AssignmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentListResult. +func (a *AssignmentListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + 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 AssignmentProperties. +func (a AssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", a.Description) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "enforcementMode", a.EnforcementMode) + populate(objectMap, "metadata", &a.Metadata) + populate(objectMap, "nonComplianceMessages", a.NonComplianceMessages) + populate(objectMap, "notScopes", a.NotScopes) + populate(objectMap, "parameters", a.Parameters) + populate(objectMap, "policyDefinitionId", a.PolicyDefinitionID) + populate(objectMap, "scope", a.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentProperties. +func (a *AssignmentProperties) 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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "enforcementMode": + err = unpopulate(val, "EnforcementMode", &a.EnforcementMode) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "nonComplianceMessages": + err = unpopulate(val, "NonComplianceMessages", &a.NonComplianceMessages) + delete(rawMsg, key) + case "notScopes": + err = unpopulate(val, "NotScopes", &a.NotScopes) + 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 "scope": + err = unpopulate(val, "Scope", &a.Scope) + 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 AssignmentUpdate. +func (a AssignmentUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "location", a.Location) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentUpdate. +func (a *AssignmentUpdate) 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 "identity": + err = unpopulate(val, "Identity", &a.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + 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 DataEffect. +func (d DataEffect) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "detailsSchema", &d.DetailsSchema) + populate(objectMap, "name", d.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataEffect. +func (d *DataEffect) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "detailsSchema": + err = unpopulate(val, "DetailsSchema", &d.DetailsSchema) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManifestCustomResourceFunctionDefinition. +func (d DataManifestCustomResourceFunctionDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowCustomProperties", d.AllowCustomProperties) + populate(objectMap, "defaultProperties", d.DefaultProperties) + populate(objectMap, "fullyQualifiedResourceType", d.FullyQualifiedResourceType) + populate(objectMap, "name", d.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestCustomResourceFunctionDefinition. +func (d *DataManifestCustomResourceFunctionDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowCustomProperties": + err = unpopulate(val, "AllowCustomProperties", &d.AllowCustomProperties) + delete(rawMsg, key) + case "defaultProperties": + err = unpopulate(val, "DefaultProperties", &d.DefaultProperties) + delete(rawMsg, key) + case "fullyQualifiedResourceType": + err = unpopulate(val, "FullyQualifiedResourceType", &d.FullyQualifiedResourceType) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManifestResourceFunctionsDefinition. +func (d DataManifestResourceFunctionsDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "custom", d.Custom) + populate(objectMap, "standard", d.Standard) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestResourceFunctionsDefinition. +func (d *DataManifestResourceFunctionsDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "custom": + err = unpopulate(val, "Custom", &d.Custom) + delete(rawMsg, key) + case "standard": + err = unpopulate(val, "Standard", &d.Standard) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataPolicyManifest. +func (d DataPolicyManifest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifest. +func (d *DataPolicyManifest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataPolicyManifestListResult. +func (d DataPolicyManifestListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestListResult. +func (d *DataPolicyManifestListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataPolicyManifestProperties. +func (d DataPolicyManifestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "effects", d.Effects) + populate(objectMap, "fieldValues", d.FieldValues) + populate(objectMap, "isBuiltInOnly", d.IsBuiltInOnly) + populate(objectMap, "namespaces", d.Namespaces) + populate(objectMap, "policyMode", d.PolicyMode) + populate(objectMap, "resourceFunctions", d.ResourceFunctions) + populate(objectMap, "resourceTypeAliases", d.ResourceTypeAliases) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestProperties. +func (d *DataPolicyManifestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "effects": + err = unpopulate(val, "Effects", &d.Effects) + delete(rawMsg, key) + case "fieldValues": + err = unpopulate(val, "FieldValues", &d.FieldValues) + delete(rawMsg, key) + case "isBuiltInOnly": + err = unpopulate(val, "IsBuiltInOnly", &d.IsBuiltInOnly) + delete(rawMsg, key) + case "namespaces": + err = unpopulate(val, "Namespaces", &d.Namespaces) + delete(rawMsg, key) + case "policyMode": + err = unpopulate(val, "PolicyMode", &d.PolicyMode) + delete(rawMsg, key) + case "resourceFunctions": + err = unpopulate(val, "ResourceFunctions", &d.ResourceFunctions) + delete(rawMsg, key) + case "resourceTypeAliases": + err = unpopulate(val, "ResourceTypeAliases", &d.ResourceTypeAliases) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Definition. +func (d Definition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 Definition. +func (d *Definition) 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 DefinitionGroup. +func (d DefinitionGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalMetadataId", d.AdditionalMetadataID) + populate(objectMap, "category", d.Category) + populate(objectMap, "description", d.Description) + populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "name", d.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionGroup. +func (d *DefinitionGroup) 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 "additionalMetadataId": + err = unpopulate(val, "AdditionalMetadataID", &d.AdditionalMetadataID) + delete(rawMsg, key) + case "category": + err = unpopulate(val, "Category", &d.Category) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefinitionListResult. +func (d DefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionListResult. +func (d *DefinitionListResult) 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 DefinitionProperties. +func (d DefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", d.Description) + populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "metadata", &d.Metadata) + populate(objectMap, "mode", d.Mode) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "policyRule", &d.PolicyRule) + populate(objectMap, "policyType", d.PolicyType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionProperties. +func (d *DefinitionProperties) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefinitionReference. +func (d DefinitionReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupNames", d.GroupNames) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "policyDefinitionId", d.PolicyDefinitionID) + populate(objectMap, "policyDefinitionReferenceId", d.PolicyDefinitionReferenceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionReference. +func (d *DefinitionReference) 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 "groupNames": + err = unpopulate(val, "GroupNames", &d.GroupNames) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &d.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &d.PolicyDefinitionReferenceID) + 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]interface{}) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) 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 "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) 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 "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + 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 Exemption. +func (e Exemption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Exemption. +func (e *Exemption) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExemptionListResult. +func (e ExemptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionListResult. +func (e *ExemptionListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 ExemptionProperties. +func (e ExemptionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", e.Description) + populate(objectMap, "displayName", e.DisplayName) + populate(objectMap, "exemptionCategory", e.ExemptionCategory) + populateTimeRFC3339(objectMap, "expiresOn", e.ExpiresOn) + populate(objectMap, "metadata", &e.Metadata) + populate(objectMap, "policyAssignmentId", e.PolicyAssignmentID) + populate(objectMap, "policyDefinitionReferenceIds", e.PolicyDefinitionReferenceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionProperties. +func (e *ExemptionProperties) 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 "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &e.DisplayName) + delete(rawMsg, key) + case "exemptionCategory": + err = unpopulate(val, "ExemptionCategory", &e.ExemptionCategory) + delete(rawMsg, key) + case "expiresOn": + err = unpopulateTimeRFC3339(val, "ExpiresOn", &e.ExpiresOn) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &e.Metadata) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &e.PolicyAssignmentID) + delete(rawMsg, key) + case "policyDefinitionReferenceIds": + err = unpopulate(val, "PolicyDefinitionReferenceIDs", &e.PolicyDefinitionReferenceIDs) + 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 Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NonComplianceMessage. +func (n NonComplianceMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "message", n.Message) + populate(objectMap, "policyDefinitionReferenceId", n.PolicyDefinitionReferenceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NonComplianceMessage. +func (n *NonComplianceMessage) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &n.Message) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &n.PolicyDefinitionReferenceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValue. +func (p ParameterDefinitionsValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowedValues", p.AllowedValues) + populate(objectMap, "defaultValue", &p.DefaultValue) + populate(objectMap, "metadata", p.Metadata) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterDefinitionsValue. +func (p *ParameterDefinitionsValue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowedValues": + err = unpopulate(val, "AllowedValues", &p.AllowedValues) + delete(rawMsg, key) + case "defaultValue": + err = unpopulate(val, "DefaultValue", &p.DefaultValue) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &p.Metadata) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValueMetadata. +func (p ParameterDefinitionsValueMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "assignPermissions", p.AssignPermissions) + populate(objectMap, "description", p.Description) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "strongType", p.StrongType) + if p.AdditionalProperties != nil { + for key, val := range p.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterDefinitionsValueMetadata. +func (p *ParameterDefinitionsValueMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignPermissions": + err = unpopulate(val, "AssignPermissions", &p.AssignPermissions) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "strongType": + err = unpopulate(val, "StrongType", &p.StrongType) + delete(rawMsg, key) + default: + if p.AdditionalProperties == nil { + p.AdditionalProperties = map[string]interface{}{} + } + if val != nil { + var aux interface{} + err = json.Unmarshal(val, &aux) + p.AdditionalProperties[key] = aux + } + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ParameterValuesValue. +func (p ParameterValuesValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", &p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterValuesValue. +func (p *ParameterValuesValue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceTypeAliases. +func (r ResourceTypeAliases) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aliases", r.Aliases) + populate(objectMap, "resourceType", r.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceTypeAliases. +func (r *ResourceTypeAliases) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aliases": + err = unpopulate(val, "Aliases", &r.Aliases) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SetDefinition. +func (s SetDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 SetDefinition. +func (s *SetDefinition) 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 SetDefinitionListResult. +func (s SetDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionListResult. +func (s *SetDefinitionListResult) 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 SetDefinitionProperties. +func (s SetDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", s.Description) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "metadata", &s.Metadata) + populate(objectMap, "parameters", s.Parameters) + populate(objectMap, "policyDefinitionGroups", s.PolicyDefinitionGroups) + populate(objectMap, "policyDefinitions", s.PolicyDefinitions) + populate(objectMap, "policyType", s.PolicyType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionProperties. +func (s *SetDefinitionProperties) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + 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 UserAssignedIdentitiesValue. +func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. +func (u *UserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Variable. +func (v Variable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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]interface{}) + 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]interface{}) + 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]interface{}) + 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]interface{}) + 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]interface{}) + populate(objectMap, "columnName", v.ColumnName) + populate(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]interface{}) + 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]interface{}) + 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]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go b/sdk/resourcemanager/resources/armpolicy/response_types.go similarity index 71% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go rename to sdk/resourcemanager/resources/armpolicy/response_types.go index 1c2641b09b03..32ae3fc0d3e2 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go +++ b/sdk/resourcemanager/resources/armpolicy/response_types.go @@ -5,6 +5,7 @@ // 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 @@ -212,3 +213,83 @@ type SetDefinitionsClientListByManagementGroupResponse struct { type SetDefinitionsClientListResponse struct { SetDefinitionListResult } + +// VariableValuesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariableValuesClient.CreateOrUpdateAtManagementGroup. +type VariableValuesClientCreateOrUpdateAtManagementGroupResponse struct { + VariableValue +} + +// VariableValuesClientCreateOrUpdateResponse contains the response from method VariableValuesClient.CreateOrUpdate. +type VariableValuesClientCreateOrUpdateResponse struct { + 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 { + VariableValue +} + +// VariableValuesClientGetResponse contains the response from method VariableValuesClient.Get. +type VariableValuesClientGetResponse struct { + VariableValue +} + +// VariableValuesClientListForManagementGroupResponse contains the response from method VariableValuesClient.ListForManagementGroup. +type VariableValuesClientListForManagementGroupResponse struct { + VariableValueListResult +} + +// VariableValuesClientListResponse contains the response from method VariableValuesClient.List. +type VariableValuesClientListResponse struct { + VariableValueListResult +} + +// VariablesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariablesClient.CreateOrUpdateAtManagementGroup. +type VariablesClientCreateOrUpdateAtManagementGroupResponse struct { + Variable +} + +// VariablesClientCreateOrUpdateResponse contains the response from method VariablesClient.CreateOrUpdate. +type VariablesClientCreateOrUpdateResponse struct { + 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 { + Variable +} + +// VariablesClientGetResponse contains the response from method VariablesClient.Get. +type VariablesClientGetResponse struct { + Variable +} + +// VariablesClientListForManagementGroupResponse contains the response from method VariablesClient.ListForManagementGroup. +type VariablesClientListForManagementGroupResponse struct { + VariableListResult +} + +// VariablesClientListResponse contains the response from method VariablesClient.List. +type VariablesClientListResponse struct { + VariableListResult +} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go rename to sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go index 0a3c0aa8498f..dc3293b6e6e2 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go @@ -5,6 +5,7 @@ // 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 @@ -413,7 +414,6 @@ func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response // the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. // If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category // match the {value}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // options - SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.List method. func (client *SetDefinitionsClient) NewListPager(options *SetDefinitionsClientListOptions) *runtime.Pager[SetDefinitionsClientListResponse] { @@ -482,7 +482,6 @@ func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (Set // NewListBuiltInPager - This operation retrieves a list of all the built-in policy set definitions that match the optional // given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all // built-in policy set definitions whose category match the {value}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.ListBuiltIn // method. @@ -555,7 +554,6 @@ func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Respons // the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. // If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category // match the {value}. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-06-01 // managementGroupID - The ID of the management group. // options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.ListByManagementGroup diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/resources/armpolicy/time_rfc3339.go index b09977b36d40..7cbd89498599 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client.go b/sdk/resourcemanager/resources/armpolicy/variables_client.go new file mode 100644 index 000000000000..904fc420438d --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/variables_client.go @@ -0,0 +1,478 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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 { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVariablesClient creates a new instance of VariablesClient with the specified values. +// subscriptionID - The ID of the target subscription. +// 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) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VariablesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + 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) { + req, err := client.createOrUpdateCreateRequest(ctx, variableName, parameters, options) + if err != nil { + return VariablesClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariablesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return VariablesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// 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}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, 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, runtime.MarshalAsJSON(req, parameters) +} + +// 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) { + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, parameters, options) + if err != nil { + return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateAtManagementGroupHandleResponse(resp) +} + +// 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.host, 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, runtime.MarshalAsJSON(req, parameters) +} + +// 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) { + req, err := client.deleteCreateRequest(ctx, variableName, options) + if err != nil { + return VariablesClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariablesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VariablesClientDeleteResponse{}, runtime.NewResponseError(resp) + } + 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}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, 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) { + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) + if err != nil { + return VariablesClientDeleteAtManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariablesClientDeleteAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VariablesClientDeleteAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + 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.host, 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) { + req, err := client.getCreateRequest(ctx, variableName, options) + if err != nil { + return VariablesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariablesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariablesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// 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}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, 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) { + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) + if err != nil { + return VariablesClientGetAtManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariablesClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariablesClientGetAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.getAtManagementGroupHandleResponse(resp) +} + +// 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.host, 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.List 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.pl.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" + 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.host, 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.ListForManagementGroup +// 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.pl.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.host, 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..c8f87792ac9c --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go @@ -0,0 +1,521 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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 { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVariableValuesClient creates a new instance of VariableValuesClient with the specified values. +// subscriptionID - The ID of the target subscription. +// 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) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VariableValuesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + 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) { + req, err := client.createOrUpdateCreateRequest(ctx, variableName, variableValueName, parameters, options) + if err != nil { + return VariableValuesClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariableValuesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return VariableValuesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// 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}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + if variableValueName == "" { + return nil, errors.New("parameter variableValueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, 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, runtime.MarshalAsJSON(req, parameters) +} + +// 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) { + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, parameters, options) + if err != nil { + return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateAtManagementGroupHandleResponse(resp) +} + +// 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.host, 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, runtime.MarshalAsJSON(req, parameters) +} + +// 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) { + req, err := client.deleteCreateRequest(ctx, variableName, variableValueName, options) + if err != nil { + return VariableValuesClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariableValuesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VariableValuesClientDeleteResponse{}, runtime.NewResponseError(resp) + } + 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}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + if variableValueName == "" { + return nil, errors.New("parameter variableValueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, 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) { + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, options) + if err != nil { + return VariableValuesClientDeleteAtManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariableValuesClientDeleteAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VariableValuesClientDeleteAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + 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.host, 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) { + req, err := client.getCreateRequest(ctx, variableName, variableValueName, options) + if err != nil { + return VariableValuesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariableValuesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariableValuesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// 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}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + if variableValueName == "" { + return nil, errors.New("parameter variableValueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, 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) { + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, options) + if err != nil { + return VariableValuesClientGetAtManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VariableValuesClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VariableValuesClientGetAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.getAtManagementGroupHandleResponse(resp) +} + +// 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.host, 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.List 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.pl.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" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if variableName == "" { + return nil, errors.New("parameter variableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, 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.ListForManagementGroup +// 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.pl.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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listForManagementGroupHandleResponse handles the ListForManagementGroup response. +func (client *VariableValuesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientListForManagementGroupResponse, error) { + result := VariableValuesClientListForManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { + return VariableValuesClientListForManagementGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go deleted file mode 100644 index ff5474789680..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go +++ /dev/null @@ -1,62 +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. - -package armpolicy_test - -import ( - "context" - "log" - - "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/tree/main/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() - client, err := armpolicy.NewDataPolicyManifestsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByPolicyMode(ctx, - "Microsoft.KeyVault.Data", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json -func ExampleDataPolicyManifestsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewDataPolicyManifestsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go deleted file mode 100644 index 1be9dd562db8..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go +++ /dev/null @@ -1,243 +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. - -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/tree/main/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() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Delete(ctx, - "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - "EnforceNaming", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json -func ExampleAssignmentsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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]interface{}{ - "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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json -func ExampleAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - "EnforceNaming", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewAssignmentsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListForResourceGroupPager("TestResourceGroup", - &armpolicy.AssignmentsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()"), - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewAssignmentsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListForResourcePager("TestResourceGroup", - "Microsoft.Compute", - "virtualMachines/MyTestVm", - "domainNames", - "MyTestComputer.cloudapp.net", - &armpolicy.AssignmentsClientListForResourceOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListForManagementGroupPager("TestManagementGroup", - &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()"), - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewAssignmentsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armpolicy.AssignmentsClientListOptions{Filter: to.Ptr("atScope()"), - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go deleted file mode 100644 index e2df125469e4..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go +++ /dev/null @@ -1,313 +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. - -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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json -func ExampleDefinitionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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]interface{}{ - "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]interface{}{ - "if": map[string]interface{}{ - "not": map[string]interface{}{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]interface{}{ - "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/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "ResourceNaming", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetBuiltIn(ctx, - "7433c107-6db4-4ad1-b57a-a76dce0154a1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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]interface{}{ - "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]interface{}{ - "if": map[string]interface{}{ - "not": map[string]interface{}{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]interface{}{ - "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/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAtManagementGroup(ctx, - "ResourceNaming", - "MyManagementGroup", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armpolicy.DefinitionsClientListOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBuiltInPager(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByManagementGroupPager("MyManagementGroup", - &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go deleted file mode 100644 index 0bc60d0dcf44..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go +++ /dev/null @@ -1,198 +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. - -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/tree/main/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() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/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() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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]interface{}{ - "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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - "DemoExpensiveVM", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewExemptionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armpolicy.ExemptionsClientListOptions{Filter: to.Ptr("atScope()")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewExemptionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListForResourceGroupPager("TestResourceGroup", - &armpolicy.ExemptionsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewExemptionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListForResourcePager("TestResourceGroup", - "Microsoft.Compute", - "virtualMachines/MyTestVm", - "domainNames", - "MyTestComputer.cloudapp.net", - &armpolicy.ExemptionsClientListForResourceOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListForManagementGroupPager("DevOrg", - &armpolicy.ExemptionsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go deleted file mode 100644 index 1f7cd32c49ed..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go +++ /dev/null @@ -1,320 +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. - -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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json -func ExampleSetDefinitionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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]interface{}{ - "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: []interface{}{ - "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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "CostManagement", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetBuiltIn(ctx, - "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("ae640e6b-ba3e-4256-9d62-2993eecfa6f2", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armpolicy.SetDefinitionsClientListOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBuiltInPager(&armpolicy.SetDefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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]interface{}{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []interface{}{ - "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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAtManagementGroup(ctx, - "CostManagement", - "MyManagementGroup", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByManagementGroupPager("MyManagementGroup", - &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go deleted file mode 100644 index 6dc9f2b0cf81..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go +++ /dev/null @@ -1,267 +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. - -package armpolicy - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AssignmentProperties. -func (a AssignmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", a.Description) - populate(objectMap, "displayName", a.DisplayName) - populate(objectMap, "enforcementMode", a.EnforcementMode) - populate(objectMap, "metadata", &a.Metadata) - populate(objectMap, "nonComplianceMessages", a.NonComplianceMessages) - populate(objectMap, "notScopes", a.NotScopes) - populate(objectMap, "parameters", a.Parameters) - populate(objectMap, "policyDefinitionId", a.PolicyDefinitionID) - populate(objectMap, "scope", a.Scope) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AssignmentUpdate. -func (a AssignmentUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", a.Identity) - populate(objectMap, "location", a.Location) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DefinitionProperties. -func (d DefinitionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", d.Description) - populate(objectMap, "displayName", d.DisplayName) - populate(objectMap, "metadata", &d.Metadata) - populate(objectMap, "mode", d.Mode) - populate(objectMap, "parameters", d.Parameters) - populate(objectMap, "policyRule", &d.PolicyRule) - populate(objectMap, "policyType", d.PolicyType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DefinitionReference. -func (d DefinitionReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "groupNames", d.GroupNames) - populate(objectMap, "parameters", d.Parameters) - populate(objectMap, "policyDefinitionId", d.PolicyDefinitionID) - populate(objectMap, "policyDefinitionReferenceId", d.PolicyDefinitionReferenceID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ExemptionProperties. -func (e ExemptionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", e.Description) - populate(objectMap, "displayName", e.DisplayName) - populate(objectMap, "exemptionCategory", e.ExemptionCategory) - populateTimeRFC3339(objectMap, "expiresOn", e.ExpiresOn) - populate(objectMap, "metadata", &e.Metadata) - populate(objectMap, "policyAssignmentId", e.PolicyAssignmentID) - populate(objectMap, "policyDefinitionReferenceIds", e.PolicyDefinitionReferenceIDs) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionProperties. -func (e *ExemptionProperties) 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 "description": - err = unpopulate(val, "Description", &e.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &e.DisplayName) - delete(rawMsg, key) - case "exemptionCategory": - err = unpopulate(val, "ExemptionCategory", &e.ExemptionCategory) - delete(rawMsg, key) - case "expiresOn": - err = unpopulateTimeRFC3339(val, "ExpiresOn", &e.ExpiresOn) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &e.Metadata) - delete(rawMsg, key) - case "policyAssignmentId": - err = unpopulate(val, "PolicyAssignmentID", &e.PolicyAssignmentID) - delete(rawMsg, key) - case "policyDefinitionReferenceIds": - err = unpopulate(val, "PolicyDefinitionReferenceIDs", &e.PolicyDefinitionReferenceIDs) - 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 Identity. -func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "principalId", i.PrincipalID) - populate(objectMap, "tenantId", i.TenantID) - populate(objectMap, "type", i.Type) - populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValue. -func (p ParameterDefinitionsValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allowedValues", p.AllowedValues) - populate(objectMap, "defaultValue", &p.DefaultValue) - populate(objectMap, "metadata", p.Metadata) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ParameterDefinitionsValueMetadata. -func (p ParameterDefinitionsValueMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "assignPermissions", p.AssignPermissions) - populate(objectMap, "description", p.Description) - populate(objectMap, "displayName", p.DisplayName) - populate(objectMap, "strongType", p.StrongType) - if p.AdditionalProperties != nil { - for key, val := range p.AdditionalProperties { - objectMap[key] = val - } - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterDefinitionsValueMetadata. -func (p *ParameterDefinitionsValueMetadata) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "assignPermissions": - err = unpopulate(val, "AssignPermissions", &p.AssignPermissions) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &p.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &p.DisplayName) - delete(rawMsg, key) - case "strongType": - err = unpopulate(val, "StrongType", &p.StrongType) - delete(rawMsg, key) - default: - if p.AdditionalProperties == nil { - p.AdditionalProperties = map[string]interface{}{} - } - if val != nil { - var aux interface{} - err = json.Unmarshal(val, &aux) - p.AdditionalProperties[key] = aux - } - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SetDefinitionProperties. -func (s SetDefinitionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", s.Description) - populate(objectMap, "displayName", s.DisplayName) - populate(objectMap, "metadata", &s.Metadata) - populate(objectMap, "parameters", s.Parameters) - populate(objectMap, "policyDefinitionGroups", s.PolicyDefinitionGroups) - populate(objectMap, "policyDefinitions", s.PolicyDefinitions) - populate(objectMap, "policyType", s.PolicyType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) 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 "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -}