From 441bcb4f9b1d5822abdce09f51099f5d6946e721 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 13 Apr 2022 08:43:49 +0000 Subject: [PATCH] CodeGen from PR 18591 in Azure/azure-rest-api-specs Merge 3c536bea49eff5a777c07d842a2074e2bbc45c89 into c5c5e1d0c31a0ceccda42505d6e872ff303d1c80 --- .../resources/armpolicy/CHANGELOG.md | 251 ++++++ .../resources/armpolicy/autorest.md | 6 +- .../resources/armpolicy/go.mod | 27 +- .../resources/armpolicy/go.sum | 25 +- ...example_datapolicymanifests_client_test.go | 57 -- ...d_example_policyassignments_client_test.go | 234 ----- ...d_example_policydefinitions_client_test.go | 286 ------ ...ed_example_policyexemptions_client_test.go | 183 ---- ...xample_policysetdefinitions_client_test.go | 341 -------- .../zz_generated_assignments_client.go | 175 ++-- .../armpolicy/zz_generated_constants.go | 56 +- ...zz_generated_datapolicymanifests_client.go | 59 +- .../zz_generated_definitions_client.go | 139 ++- .../zz_generated_exemptions_client.go | 165 +++- .../armpolicy/zz_generated_models.go | 395 +-------- .../armpolicy/zz_generated_models_serde.go | 375 ++++++++ .../armpolicy/zz_generated_pagers.go | 827 ------------------ .../armpolicy/zz_generated_response_types.go | 273 +----- .../zz_generated_setdefinitions_client.go | 139 ++- .../armpolicy/zz_generated_time_rfc3339.go | 4 +- 20 files changed, 1181 insertions(+), 2836 deletions(-) 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 create mode 100644 sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/zz_generated_pagers.go diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index 85724582202d..21d854d06e28 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,256 @@ # Release History +## 0.4.0 (2022-04-13) +### Breaking Changes + +- Function `*DefinitionsClient.ListByManagementGroup` return value(s) have been changed from `(*DefinitionsClientListByManagementGroupPager)` to `(*runtime.Pager[DefinitionsClientListByManagementGroupResponse])` +- Function `*AssignmentsClient.List` return value(s) have been changed from `(*AssignmentsClientListPager)` to `(*runtime.Pager[AssignmentsClientListResponse])` +- Function `NewDataPolicyManifestsClient` return value(s) have been changed from `(*DataPolicyManifestsClient)` to `(*DataPolicyManifestsClient, error)` +- Function `NewExemptionsClient` return value(s) have been changed from `(*ExemptionsClient)` to `(*ExemptionsClient, error)` +- Function `*ExemptionsClient.ListForResource` return value(s) have been changed from `(*ExemptionsClientListForResourcePager)` to `(*runtime.Pager[ExemptionsClientListForResourceResponse])` +- Function `NewAssignmentsClient` return value(s) have been changed from `(*AssignmentsClient)` to `(*AssignmentsClient, error)` +- Function `NewDefinitionsClient` return value(s) have been changed from `(*DefinitionsClient)` to `(*DefinitionsClient, error)` +- Function `*DefinitionsClient.ListBuiltIn` return value(s) have been changed from `(*DefinitionsClientListBuiltInPager)` to `(*runtime.Pager[DefinitionsClientListBuiltInResponse])` +- Function `*SetDefinitionsClient.ListByManagementGroup` return value(s) have been changed from `(*SetDefinitionsClientListByManagementGroupPager)` to `(*runtime.Pager[SetDefinitionsClientListByManagementGroupResponse])` +- Function `*AssignmentsClient.ListForResource` return value(s) have been changed from `(*AssignmentsClientListForResourcePager)` to `(*runtime.Pager[AssignmentsClientListForResourceResponse])` +- Function `*ExemptionsClient.ListForManagementGroup` return value(s) have been changed from `(*ExemptionsClientListForManagementGroupPager)` to `(*runtime.Pager[ExemptionsClientListForManagementGroupResponse])` +- Function `*DefinitionsClient.List` return value(s) have been changed from `(*DefinitionsClientListPager)` to `(*runtime.Pager[DefinitionsClientListResponse])` +- Function `*SetDefinitionsClient.List` return value(s) have been changed from `(*SetDefinitionsClientListPager)` to `(*runtime.Pager[SetDefinitionsClientListResponse])` +- Function `NewSetDefinitionsClient` return value(s) have been changed from `(*SetDefinitionsClient)` to `(*SetDefinitionsClient, error)` +- Function `*ExemptionsClient.List` return value(s) have been changed from `(*ExemptionsClientListPager)` to `(*runtime.Pager[ExemptionsClientListResponse])` +- Function `*SetDefinitionsClient.ListBuiltIn` return value(s) have been changed from `(*SetDefinitionsClientListBuiltInPager)` to `(*runtime.Pager[SetDefinitionsClientListBuiltInResponse])` +- Function `*AssignmentsClient.ListForResourceGroup` return value(s) have been changed from `(*AssignmentsClientListForResourceGroupPager)` to `(*runtime.Pager[AssignmentsClientListForResourceGroupResponse])` +- Function `*DataPolicyManifestsClient.List` return value(s) have been changed from `(*DataPolicyManifestsClientListPager)` to `(*runtime.Pager[DataPolicyManifestsClientListResponse])` +- Function `*ExemptionsClient.ListForResourceGroup` return value(s) have been changed from `(*ExemptionsClientListForResourceGroupPager)` to `(*runtime.Pager[ExemptionsClientListForResourceGroupResponse])` +- Function `*AssignmentsClient.ListForManagementGroup` return value(s) have been changed from `(*AssignmentsClientListForManagementGroupPager)` to `(*runtime.Pager[AssignmentsClientListForManagementGroupResponse])` +- Function `*AssignmentsClientListForResourcePager.Err` has been removed +- Function `AliasType.ToPtr` has been removed +- Function `*AssignmentsClientListPager.PageResponse` has been removed +- Function `*DefinitionsClientListByManagementGroupPager.NextPage` has been removed +- Function `*DataPolicyManifestsClientListPager.PageResponse` has been removed +- Function `*ExemptionsClientListForResourcePager.PageResponse` has been removed +- Function `*ExemptionsClientListPager.Err` has been removed +- Function `*SetDefinitionsClientListBuiltInPager.Err` has been removed +- Function `*AssignmentsClientListPager.Err` has been removed +- Function `*SetDefinitionsClientListByManagementGroupPager.NextPage` has been removed +- Function `*ExemptionsClientListForManagementGroupPager.Err` has been removed +- Function `PolicyType.ToPtr` has been removed +- Function `*AssignmentsClientListForResourceGroupPager.Err` has been removed +- Function `*AssignmentsClientListForResourceGroupPager.PageResponse` has been removed +- Function `*ExemptionsClientListForResourcePager.Err` has been removed +- Function `ExemptionCategory.ToPtr` has been removed +- Function `*DefinitionsClientListByManagementGroupPager.PageResponse` has been removed +- Function `*DefinitionsClientListBuiltInPager.NextPage` has been removed +- Function `AliasPathTokenType.ToPtr` has been removed +- Function `*ExemptionsClientListForResourceGroupPager.Err` has been removed +- Function `*SetDefinitionsClientListPager.NextPage` has been removed +- Function `EnforcementMode.ToPtr` has been removed +- Function `*AssignmentsClientListPager.NextPage` has been removed +- Function `*DataPolicyManifestsClientListPager.NextPage` has been removed +- Function `*DefinitionsClientListByManagementGroupPager.Err` has been removed +- Function `*SetDefinitionsClientListByManagementGroupPager.PageResponse` has been removed +- Function `*AssignmentsClientListForManagementGroupPager.Err` has been removed +- Function `*AssignmentsClientListForManagementGroupPager.PageResponse` has been removed +- Function `*ExemptionsClientListForResourceGroupPager.PageResponse` has been removed +- Function `*SetDefinitionsClientListBuiltInPager.PageResponse` has been removed +- Function `AliasPatternType.ToPtr` has been removed +- Function `*DataPolicyManifestsClientListPager.Err` has been removed +- Function `*DefinitionsClientListBuiltInPager.Err` has been removed +- Function `*AssignmentsClientListForResourcePager.NextPage` has been removed +- Function `*ExemptionsClientListForManagementGroupPager.PageResponse` has been removed +- Function `*AssignmentsClientListForResourceGroupPager.NextPage` has been removed +- Function `*ExemptionsClientListPager.NextPage` has been removed +- Function `*SetDefinitionsClientListByManagementGroupPager.Err` has been removed +- Function `*AssignmentsClientListForResourcePager.PageResponse` has been removed +- Function `*SetDefinitionsClientListBuiltInPager.NextPage` has been removed +- Function `*DefinitionsClientListPager.PageResponse` has been removed +- Function `*DefinitionsClientListPager.NextPage` has been removed +- Function `AliasPathAttributes.ToPtr` has been removed +- Function `*SetDefinitionsClientListPager.PageResponse` has been removed +- Function `*ExemptionsClientListPager.PageResponse` has been removed +- Function `CreatedByType.ToPtr` has been removed +- Function `ResourceIdentityType.ToPtr` has been removed +- Function `*DefinitionsClientListBuiltInPager.PageResponse` has been removed +- Function `*SetDefinitionsClientListPager.Err` has been removed +- Function `ParameterType.ToPtr` has been removed +- Function `*ExemptionsClientListForResourcePager.NextPage` has been removed +- Function `*DefinitionsClientListPager.Err` has been removed +- Function `*ExemptionsClientListForResourceGroupPager.NextPage` has been removed +- Function `*ExemptionsClientListForManagementGroupPager.NextPage` has been removed +- Function `*AssignmentsClientListForManagementGroupPager.NextPage` has been removed +- Struct `AssignmentsClientCreateByIDResult` has been removed +- Struct `AssignmentsClientCreateResult` has been removed +- Struct `AssignmentsClientDeleteByIDResult` has been removed +- Struct `AssignmentsClientDeleteResult` has been removed +- Struct `AssignmentsClientGetByIDResult` has been removed +- Struct `AssignmentsClientGetResult` has been removed +- Struct `AssignmentsClientListForManagementGroupPager` has been removed +- Struct `AssignmentsClientListForManagementGroupResult` has been removed +- Struct `AssignmentsClientListForResourceGroupPager` has been removed +- Struct `AssignmentsClientListForResourceGroupResult` has been removed +- Struct `AssignmentsClientListForResourcePager` has been removed +- Struct `AssignmentsClientListForResourceResult` has been removed +- Struct `AssignmentsClientListPager` has been removed +- Struct `AssignmentsClientListResult` has been removed +- Struct `AssignmentsClientUpdateByIDResult` has been removed +- Struct `AssignmentsClientUpdateResult` has been removed +- Struct `DataPolicyManifestsClientGetByPolicyModeResult` has been removed +- Struct `DataPolicyManifestsClientListPager` has been removed +- Struct `DataPolicyManifestsClientListResult` has been removed +- Struct `DefinitionsClientCreateOrUpdateAtManagementGroupResult` has been removed +- Struct `DefinitionsClientCreateOrUpdateResult` has been removed +- Struct `DefinitionsClientGetAtManagementGroupResult` has been removed +- Struct `DefinitionsClientGetBuiltInResult` has been removed +- Struct `DefinitionsClientGetResult` has been removed +- Struct `DefinitionsClientListBuiltInPager` has been removed +- Struct `DefinitionsClientListBuiltInResult` has been removed +- Struct `DefinitionsClientListByManagementGroupPager` has been removed +- Struct `DefinitionsClientListByManagementGroupResult` has been removed +- Struct `DefinitionsClientListPager` has been removed +- Struct `DefinitionsClientListResult` has been removed +- Struct `ExemptionsClientCreateOrUpdateResult` has been removed +- Struct `ExemptionsClientGetResult` has been removed +- Struct `ExemptionsClientListForManagementGroupPager` has been removed +- Struct `ExemptionsClientListForManagementGroupResult` has been removed +- Struct `ExemptionsClientListForResourceGroupPager` has been removed +- Struct `ExemptionsClientListForResourceGroupResult` has been removed +- Struct `ExemptionsClientListForResourcePager` has been removed +- Struct `ExemptionsClientListForResourceResult` has been removed +- Struct `ExemptionsClientListPager` has been removed +- Struct `ExemptionsClientListResult` has been removed +- Struct `SetDefinitionsClientCreateOrUpdateAtManagementGroupResult` has been removed +- Struct `SetDefinitionsClientCreateOrUpdateResult` has been removed +- Struct `SetDefinitionsClientGetAtManagementGroupResult` has been removed +- Struct `SetDefinitionsClientGetBuiltInResult` has been removed +- Struct `SetDefinitionsClientGetResult` has been removed +- Struct `SetDefinitionsClientListBuiltInPager` has been removed +- Struct `SetDefinitionsClientListBuiltInResult` has been removed +- Struct `SetDefinitionsClientListByManagementGroupPager` has been removed +- Struct `SetDefinitionsClientListByManagementGroupResult` has been removed +- Struct `SetDefinitionsClientListPager` has been removed +- Struct `SetDefinitionsClientListResult` has been removed +- Field `AssignmentsClientGetByIDResult` of struct `AssignmentsClientGetByIDResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientGetByIDResponse` has been removed +- Field `SetDefinitionsClientListByManagementGroupResult` of struct `SetDefinitionsClientListByManagementGroupResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientListByManagementGroupResponse` has been removed +- Field `AssignmentsClientGetResult` of struct `AssignmentsClientGetResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientGetResponse` has been removed +- Field `SetDefinitionsClientGetAtManagementGroupResult` of struct `SetDefinitionsClientGetAtManagementGroupResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientGetAtManagementGroupResponse` has been removed +- Field `DefinitionsClientListBuiltInResult` of struct `DefinitionsClientListBuiltInResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientListBuiltInResponse` has been removed +- Field `AssignmentsClientUpdateResult` of struct `AssignmentsClientUpdateResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientUpdateResponse` has been removed +- Field `SetDefinitionsClientCreateOrUpdateAtManagementGroupResult` of struct `SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse` has been removed +- Field `SetDefinitionsClientGetBuiltInResult` of struct `SetDefinitionsClientGetBuiltInResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientGetBuiltInResponse` has been removed +- Field `AssignmentsClientDeleteResult` of struct `AssignmentsClientDeleteResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientDeleteResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientDeleteResponse` has been removed +- Field `ExemptionsClientListForManagementGroupResult` of struct `ExemptionsClientListForManagementGroupResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientListForManagementGroupResponse` has been removed +- Field `DefinitionsClientCreateOrUpdateResult` of struct `DefinitionsClientCreateOrUpdateResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientCreateOrUpdateResponse` has been removed +- Field `ExemptionsClientListForResourceGroupResult` of struct `ExemptionsClientListForResourceGroupResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientListForResourceGroupResponse` has been removed +- Field `AssignmentsClientListForResourceResult` of struct `AssignmentsClientListForResourceResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientListForResourceResponse` has been removed +- Field `DataPolicyManifestsClientListResult` of struct `DataPolicyManifestsClientListResponse` has been removed +- Field `RawResponse` of struct `DataPolicyManifestsClientListResponse` has been removed +- Field `ExemptionsClientGetResult` of struct `ExemptionsClientGetResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientGetResponse` has been removed +- Field `AssignmentsClientListResult` of struct `AssignmentsClientListResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientListResponse` has been removed +- Field `ExemptionsClientCreateOrUpdateResult` of struct `ExemptionsClientCreateOrUpdateResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientCreateOrUpdateResponse` has been removed +- Field `SetDefinitionsClientListResult` of struct `SetDefinitionsClientListResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientListResponse` has been removed +- Field `ExemptionsClientListResult` of struct `ExemptionsClientListResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientListResponse` has been removed +- Field `AssignmentsClientCreateByIDResult` of struct `AssignmentsClientCreateByIDResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientCreateByIDResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientDeleteAtManagementGroupResponse` has been removed +- Field `DefinitionsClientCreateOrUpdateAtManagementGroupResult` of struct `DefinitionsClientCreateOrUpdateAtManagementGroupResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientCreateOrUpdateAtManagementGroupResponse` has been removed +- Field `AssignmentsClientListForManagementGroupResult` of struct `AssignmentsClientListForManagementGroupResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientListForManagementGroupResponse` has been removed +- Field `DataPolicyManifestsClientGetByPolicyModeResult` of struct `DataPolicyManifestsClientGetByPolicyModeResponse` has been removed +- Field `RawResponse` of struct `DataPolicyManifestsClientGetByPolicyModeResponse` has been removed +- Field `AssignmentsClientListForResourceGroupResult` of struct `AssignmentsClientListForResourceGroupResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientListForResourceGroupResponse` has been removed +- Field `DefinitionsClientGetAtManagementGroupResult` of struct `DefinitionsClientGetAtManagementGroupResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientGetAtManagementGroupResponse` has been removed +- Field `ExemptionsClientListForResourceResult` of struct `ExemptionsClientListForResourceResponse` has been removed +- Field `RawResponse` of struct `ExemptionsClientListForResourceResponse` has been removed +- Field `DefinitionsClientGetBuiltInResult` of struct `DefinitionsClientGetBuiltInResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientGetBuiltInResponse` has been removed +- Field `AssignmentsClientCreateResult` of struct `AssignmentsClientCreateResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientCreateResponse` has been removed +- Field `AssignmentsClientUpdateByIDResult` of struct `AssignmentsClientUpdateByIDResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientUpdateByIDResponse` has been removed +- Field `DefinitionsClientGetResult` of struct `DefinitionsClientGetResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientGetResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientDeleteAtManagementGroupResponse` has been removed +- Field `DefinitionsClientListByManagementGroupResult` of struct `DefinitionsClientListByManagementGroupResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientListByManagementGroupResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientDeleteResponse` has been removed +- Field `SetDefinitionsClientListBuiltInResult` of struct `SetDefinitionsClientListBuiltInResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientListBuiltInResponse` has been removed +- Field `SetDefinitionsClientGetResult` of struct `SetDefinitionsClientGetResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientGetResponse` has been removed +- Field `SetDefinitionsClientCreateOrUpdateResult` of struct `SetDefinitionsClientCreateOrUpdateResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientCreateOrUpdateResponse` has been removed +- Field `AssignmentsClientDeleteByIDResult` of struct `AssignmentsClientDeleteByIDResponse` has been removed +- Field `RawResponse` of struct `AssignmentsClientDeleteByIDResponse` has been removed +- Field `RawResponse` of struct `SetDefinitionsClientDeleteResponse` has been removed +- Field `DefinitionsClientListResult` of struct `DefinitionsClientListResponse` has been removed +- Field `RawResponse` of struct `DefinitionsClientListResponse` has been removed + +### Features Added + +- New function `ErrorResponse.MarshalJSON() ([]byte, error)` +- New struct `CloudError` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorResponse` +- New anonymous field `SetDefinition` in struct `SetDefinitionsClientCreateOrUpdateResponse` +- New anonymous field `SetDefinitionListResult` in struct `SetDefinitionsClientListResponse` +- New anonymous field `Definition` in struct `DefinitionsClientGetBuiltInResponse` +- New anonymous field `DataPolicyManifestListResult` in struct `DataPolicyManifestsClientListResponse` +- New anonymous field `ExemptionListResult` in struct `ExemptionsClientListForResourceResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientDeleteResponse` +- New anonymous field `ExemptionListResult` in struct `ExemptionsClientListForManagementGroupResponse` +- New anonymous field `SetDefinition` in struct `SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse` +- New anonymous field `SetDefinition` in struct `SetDefinitionsClientGetResponse` +- New anonymous field `ExemptionListResult` in struct `ExemptionsClientListForResourceGroupResponse` +- New anonymous field `Exemption` in struct `ExemptionsClientGetResponse` +- New anonymous field `DefinitionListResult` in struct `DefinitionsClientListByManagementGroupResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientUpdateResponse` +- New anonymous field `AssignmentListResult` in struct `AssignmentsClientListForResourceResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientCreateResponse` +- New anonymous field `AssignmentListResult` in struct `AssignmentsClientListForManagementGroupResponse` +- New anonymous field `Exemption` in struct `ExemptionsClientCreateOrUpdateResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientUpdateByIDResponse` +- New anonymous field `ExemptionListResult` in struct `ExemptionsClientListResponse` +- New anonymous field `SetDefinition` in struct `SetDefinitionsClientGetAtManagementGroupResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientGetByIDResponse` +- New anonymous field `DefinitionListResult` in struct `DefinitionsClientListBuiltInResponse` +- New anonymous field `SetDefinitionListResult` in struct `SetDefinitionsClientListByManagementGroupResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientDeleteByIDResponse` +- New anonymous field `Definition` in struct `DefinitionsClientCreateOrUpdateAtManagementGroupResponse` +- New anonymous field `Definition` in struct `DefinitionsClientGetAtManagementGroupResponse` +- New anonymous field `AssignmentListResult` in struct `AssignmentsClientListForResourceGroupResponse` +- New anonymous field `DataPolicyManifest` in struct `DataPolicyManifestsClientGetByPolicyModeResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientCreateByIDResponse` +- New anonymous field `SetDefinitionListResult` in struct `SetDefinitionsClientListBuiltInResponse` +- New anonymous field `AssignmentListResult` in struct `AssignmentsClientListResponse` +- New anonymous field `SetDefinition` in struct `SetDefinitionsClientGetBuiltInResponse` +- New anonymous field `Assignment` in struct `AssignmentsClientGetResponse` +- New anonymous field `Definition` in struct `DefinitionsClientCreateOrUpdateResponse` +- New anonymous field `DefinitionListResult` in struct `DefinitionsClientListResponse` +- New anonymous field `Definition` in struct `DefinitionsClientGetResponse` + + ## 0.3.1 (2022-02-22) ### Other Changes diff --git a/sdk/resourcemanager/resources/armpolicy/autorest.md b/sdk/resourcemanager/resources/armpolicy/autorest.md index 4acf44ec2460..449e3f8368ec 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/1118376e6b4c59716f4a2bcf3ddea212aeee5536/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/1118376e6b4c59716f4a2bcf3ddea212aeee5536/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.3.1 +module-version: 0.4.0 package-policy: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index 1ec4a4c87eda..2c6cb5cb94dc 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -1,10 +1,29 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy -go 1.16 +go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v0.22.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.1 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.3.0 github.com/stretchr/testify v1.7.0 ) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.4.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dnaeon/go-vcr v1.1.0 // indirect + github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect + golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/resources/armpolicy/go.sum b/sdk/resourcemanager/resources/armpolicy/go.sum index 861905ed56b2..facd9999ed64 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.sum +++ b/sdk/resourcemanager/resources/armpolicy/go.sum @@ -1,16 +1,13 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.22.0 h1:zBJcBJwte0x6PcPK7XaWDMvK2o2ZM2f1sMaqNNavQ5g= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.22.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0/go.mod h1:TmXReXZ9yPp5D5TBRMTAtyz+UyOl15Py4hL5E5p6igQ= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.1 h1:RxemzI2cHD0A8WyMqHu/UnDjfpGES/cmjtPbQoktWqs= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.1/go.mod h1:+nVKciyKD2J9TyVcEQ82Bo9b+3F92PiQfHrIE/zqLqM= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 h1:D7l5jspkc4kwBYRWoZE4DQnu6LVpLwDsMZjBKS4wZLQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0/go.mod h1:w5pDIZuawUmY3Bj4tVx3Xb8KS96ToB0j315w9rqpAg0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 h1:NVS/4LOQfkBpk+B1VopIzv1ptmYeEskA8w/3K/w7vjo= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0/go.mod h1:RG0cZndeZM17StwohYclmcXSr4oOJ8b1I5hB8llIc6Y= github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo= github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.1.0 h1:/hWqo5bAXoNK7svf5GvgpXFPzOCpM29/Eu+WqcE34Uk= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.1.0/go.mod h1:wXFq4k1znCwV7Bw70gw4UDNYKv/nrCUr70hjUmOj1Jo= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.3.1 h1:EXTDtCSTfPauGawsG+Ae/W46B1PkrgzuKNrcFqy4ljM= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.3.1/go.mod h1:PoA99xQAlN13MyUjzgIPWMZEr0etHpYSuT25LmhR3zQ= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.3.0 h1:gYG7I0WxtCnHSWOFLbWCHLBWr+yzI5UeU9KuGZajf5U= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.3.0/go.mod h1:bwEUbGO8V/7KcrqwO14ADZ0m4AkTvSKx3ma68FRc3Bg= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.4.0 h1:TSBK+EXu33WBNrYhWmOecKJAl4z1Z5dtbDmqOzd1zGk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.4.0/go.mod h1:tt77DwGu+r0Ued27YQPhiW8h8YWpYwpfOfi5uRpRMTg= github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -21,7 +18,6 @@ github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/ github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -41,21 +37,16 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNm golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 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 db36d48670d6..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go +++ /dev/null @@ -1,57 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// 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" -) - -// x-ms-original-file: 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 := armpolicy.NewDataPolicyManifestsClient(cred, nil) - res, err := client.GetByPolicyMode(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.DataPolicyManifestsClientGetByPolicyModeResult) -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json -func ExampleDataPolicyManifestsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewDataPolicyManifestsClient(cred, nil) - pager := client.List(&armpolicy.DataPolicyManifestsClientListOptions{Filter: nil}) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", 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 2ccaf7efa55d..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go +++ /dev/null @@ -1,234 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// 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" -) - -// x-ms-original-file: 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 := armpolicy.NewAssignmentsClient("", cred, nil) - res, err := client.Delete(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.AssignmentsClientDeleteResult) -} - -// x-ms-original-file: 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 := armpolicy.NewAssignmentsClient("", cred, nil) - _, err = client.Create(ctx, - "", - "", - armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - Metadata: map[string]interface{}{ - "assignedBy": "Special Someone", - }, - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.StringPtr(""), - }}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: map[string]interface{}{ - "0": "D", - "1": "e", - "2": "p", - "3": "t", - "4": "A", - }, - }, - "suffix": { - Value: map[string]interface{}{ - "0": "-", - "1": "L", - "2": "C", - }, - }, - }, - PolicyDefinitionID: to.StringPtr(""), - }, - }, - nil) - if err != nil { - log.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewAssignmentsClient("", cred, nil) - res, err := client.Get(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.AssignmentsClientGetResult) -} - -// x-ms-original-file: 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 := armpolicy.NewAssignmentsClient("", cred, nil) - res, err := client.Update(ctx, - "", - "", - armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: armpolicy.ResourceIdentityTypeSystemAssigned.ToPtr(), - }, - Location: to.StringPtr(""), - }, - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.AssignmentsClientUpdateResult) -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResourceGroup.json -func ExampleAssignmentsClient_ListForResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewAssignmentsClient("", cred, nil) - pager := client.ListForResourceGroup("", - &armpolicy.AssignmentsClientListForResourceGroupOptions{Filter: to.StringPtr(""), - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResource.json -func ExampleAssignmentsClient_ListForResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewAssignmentsClient("", cred, nil) - pager := client.ListForResource("", - "", - "", - "", - "", - &armpolicy.AssignmentsClientListForResourceOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForManagementGroup.json -func ExampleAssignmentsClient_ListForManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewAssignmentsClient("", cred, nil) - pager := client.ListForManagementGroup("", - &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.StringPtr(""), - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignments.json -func ExampleAssignmentsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewAssignmentsClient("", cred, nil) - pager := client.List(&armpolicy.AssignmentsClientListOptions{Filter: to.StringPtr(""), - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", 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 8dd5f34db3a1..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go +++ /dev/null @@ -1,286 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// 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" -) - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - _, err = client.CreateOrUpdate(ctx, - "", - armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - Metadata: map[string]interface{}{ - "category": "Naming", - }, - Mode: to.StringPtr(""), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: armpolicy.ParameterType("String").ToPtr(), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - }, - }, - "suffix": { - Type: armpolicy.ParameterType("String").ToPtr(), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - }, - }, - }, - 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.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - _, err = client.Delete(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - res, err := client.Get(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.DefinitionsClientGetResult) -} - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - res, err := client.GetBuiltIn(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.DefinitionsClientGetBuiltInResult) -} - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - _, err = client.CreateOrUpdateAtManagementGroup(ctx, - "", - "", - armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - Metadata: map[string]interface{}{ - "category": "Naming", - }, - Mode: to.StringPtr(""), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: armpolicy.ParameterType("String").ToPtr(), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - }, - }, - "suffix": { - Type: armpolicy.ParameterType("String").ToPtr(), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - }, - }, - }, - 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.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - _, err = client.DeleteAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewDefinitionsClient("", cred, nil) - res, err := client.GetAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.DefinitionsClientGetAtManagementGroupResult) -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json -func ExampleDefinitionsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewDefinitionsClient("", cred, nil) - pager := client.List(&armpolicy.DefinitionsClientListOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json -func ExampleDefinitionsClient_ListBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewDefinitionsClient("", cred, nil) - pager := client.ListBuiltIn(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json -func ExampleDefinitionsClient_ListByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewDefinitionsClient("", cred, nil) - pager := client.ListByManagementGroup("", - &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", 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 23441812810f..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go +++ /dev/null @@ -1,183 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// 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" -) - -// x-ms-original-file: 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 := armpolicy.NewExemptionsClient("", cred, nil) - _, err = client.Delete(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewExemptionsClient("", cred, nil) - res, err := client.CreateOrUpdate(ctx, - "", - "", - armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - ExemptionCategory: armpolicy.ExemptionCategory("Waiver").ToPtr(), - Metadata: map[string]interface{}{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.StringPtr(""), - PolicyDefinitionReferenceIDs: []*string{ - to.StringPtr("Limit_Skus")}, - }, - }, - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.ExemptionsClientCreateOrUpdateResult) -} - -// x-ms-original-file: 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 := armpolicy.NewExemptionsClient("", cred, nil) - res, err := client.Get(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.ExemptionsClientGetResult) -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForSubscription.json -func ExampleExemptionsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewExemptionsClient("", cred, nil) - pager := client.List(&armpolicy.ExemptionsClientListOptions{Filter: to.StringPtr("")}) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json -func ExampleExemptionsClient_ListForResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewExemptionsClient("", cred, nil) - pager := client.ListForResourceGroup("", - &armpolicy.ExemptionsClientListForResourceGroupOptions{Filter: to.StringPtr("")}) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResource.json -func ExampleExemptionsClient_ListForResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewExemptionsClient("", cred, nil) - pager := client.ListForResource("", - "", - "", - "", - "", - &armpolicy.ExemptionsClientListForResourceOptions{Filter: nil}) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json -func ExampleExemptionsClient_ListForManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewExemptionsClient("", cred, nil) - pager := client.ListForManagementGroup("", - &armpolicy.ExemptionsClientListForManagementGroupOptions{Filter: to.StringPtr("")}) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", 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 15fde998e955..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go +++ /dev/null @@ -1,341 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// 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" -) - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - res, err := client.CreateOrUpdate(ctx, - "", - armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - Metadata: map[string]interface{}{ - "category": "Cost Management", - }, - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "namePrefix": { - Type: armpolicy.ParameterType("String").ToPtr(), - DefaultValue: map[string]interface{}{ - "0": "m", - "1": "y", - "2": "P", - "3": "r", - "4": "e", - "5": "f", - "6": "i", - "7": "x", - }, - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - DisplayName: to.StringPtr(""), - }, - }, - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: map[string]interface{}{ - "0": "Standard_GRS", - "1": "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.StringPtr(""), - PolicyDefinitionReferenceID: to.StringPtr(""), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: map[string]interface{}{ - "0": "[", - "1": "p", - "2": "a", - "3": "r", - "4": "a", - "5": "m", - "6": "e", - "7": "t", - "8": "e", - "9": "r", - "10": "s", - "11": "(", - "12": "'", - "13": "n", - "14": "a", - "15": "m", - "16": "e", - "17": "P", - "18": "r", - "19": "e", - "20": "f", - "21": "i", - "22": "x", - "23": "'", - "24": ")", - "25": "]", - }, - }, - "suffix": { - Value: map[string]interface{}{ - "0": "-", - "1": "L", - "2": "C", - }, - }, - }, - PolicyDefinitionID: to.StringPtr(""), - PolicyDefinitionReferenceID: to.StringPtr(""), - }}, - }, - }, - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.SetDefinitionsClientCreateOrUpdateResult) -} - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - _, err = client.Delete(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - res, err := client.Get(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.SetDefinitionsClientGetResult) -} - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - res, err := client.GetBuiltIn(ctx, - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.SetDefinitionsClientGetBuiltInResult) -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json -func ExampleSetDefinitionsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewSetDefinitionsClient("", cred, nil) - pager := client.List(&armpolicy.SetDefinitionsClientListOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json -func ExampleSetDefinitionsClient_ListBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewSetDefinitionsClient("", cred, nil) - pager := client.ListBuiltIn(&armpolicy.SetDefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - res, err := client.CreateOrUpdateAtManagementGroup(ctx, - "", - "", - armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.StringPtr(""), - DisplayName: to.StringPtr(""), - Metadata: map[string]interface{}{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: map[string]interface{}{ - "0": "Standard_GRS", - "1": "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.StringPtr(""), - PolicyDefinitionReferenceID: to.StringPtr(""), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: map[string]interface{}{ - "0": "D", - "1": "e", - "2": "p", - "3": "t", - "4": "A", - }, - }, - "suffix": { - Value: map[string]interface{}{ - "0": "-", - "1": "L", - "2": "C", - }, - }, - }, - PolicyDefinitionID: to.StringPtr(""), - PolicyDefinitionReferenceID: to.StringPtr(""), - }}, - }, - }, - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.SetDefinitionsClientCreateOrUpdateAtManagementGroupResult) -} - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - _, err = client.DeleteAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } -} - -// x-ms-original-file: 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 := armpolicy.NewSetDefinitionsClient("", cred, nil) - res, err := client.GetAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.SetDefinitionsClientGetAtManagementGroupResult) -} - -// x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json -func ExampleSetDefinitionsClient_ListByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armpolicy.NewSetDefinitionsClient("", cred, nil) - pager := client.ListByManagementGroup("", - &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go index 4336cb9065c1..d67372be9e4e 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_assignments_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -14,6 +14,7 @@ import ( "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" @@ -34,20 +35,24 @@ type AssignmentsClient struct { // 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 NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AssignmentsClient { +func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsClient, error) { if options == nil { options = &arm.ClientOptions{} } - ep := options.Endpoint - if len(ep) == 0 { - ep = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.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 := &AssignmentsClient{ subscriptionID: subscriptionID, - host: string(ep), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + host: ep, + pl: pl, } - return client + return client, nil } // Create - This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply @@ -98,7 +103,7 @@ func (client *AssignmentsClient) createCreateRequest(ctx context.Context, scope // createHandleResponse handles the Create response. func (client *AssignmentsClient) createHandleResponse(resp *http.Response) (AssignmentsClientCreateResponse, error) { - result := AssignmentsClientCreateResponse{RawResponse: resp} + result := AssignmentsClientCreateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientCreateResponse{}, err } @@ -149,7 +154,7 @@ func (client *AssignmentsClient) createByIDCreateRequest(ctx context.Context, po // createByIDHandleResponse handles the CreateByID response. func (client *AssignmentsClient) createByIDHandleResponse(resp *http.Response) (AssignmentsClientCreateByIDResponse, error) { - result := AssignmentsClientCreateByIDResponse{RawResponse: resp} + result := AssignmentsClientCreateByIDResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientCreateByIDResponse{}, err } @@ -203,7 +208,7 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, scope // deleteHandleResponse handles the Delete response. func (client *AssignmentsClient) deleteHandleResponse(resp *http.Response) (AssignmentsClientDeleteResponse, error) { - result := AssignmentsClientDeleteResponse{RawResponse: resp} + result := AssignmentsClientDeleteResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientDeleteResponse{}, err } @@ -252,7 +257,7 @@ func (client *AssignmentsClient) deleteByIDCreateRequest(ctx context.Context, po // deleteByIDHandleResponse handles the DeleteByID response. func (client *AssignmentsClient) deleteByIDHandleResponse(resp *http.Response) (AssignmentsClientDeleteByIDResponse, error) { - result := AssignmentsClientDeleteByIDResponse{RawResponse: resp} + result := AssignmentsClientDeleteByIDResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientDeleteByIDResponse{}, err } @@ -304,7 +309,7 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope str // getHandleResponse handles the Get response. func (client *AssignmentsClient) getHandleResponse(resp *http.Response) (AssignmentsClientGetResponse, error) { - result := AssignmentsClientGetResponse{RawResponse: resp} + result := AssignmentsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientGetResponse{}, err } @@ -352,7 +357,7 @@ func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, polic // getByIDHandleResponse handles the GetByID response. func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (AssignmentsClientGetByIDResponse, error) { - result := AssignmentsClientGetByIDResponse{RawResponse: resp} + result := AssignmentsClientGetByIDResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientGetByIDResponse{}, err } @@ -372,16 +377,32 @@ func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (Ass // definition whose id is {value}. // If the operation fails it returns an *azcore.ResponseError type. // options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.List method. -func (client *AssignmentsClient) List(options *AssignmentsClientListOptions) *AssignmentsClientListPager { - return &AssignmentsClientListPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) +func (client *AssignmentsClient) List(options *AssignmentsClientListOptions) *runtime.Pager[AssignmentsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[AssignmentsClientListResponse]{ + More: func(page AssignmentsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp AssignmentsClientListResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.AssignmentListResult.NextLink) + Fetcher: func(ctx context.Context, page *AssignmentsClientListResponse) (AssignmentsClientListResponse, 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 AssignmentsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AssignmentsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AssignmentsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) }, - } + }) } // listCreateRequest creates the List request. @@ -412,7 +433,7 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options // listHandleResponse handles the List response. func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (AssignmentsClientListResponse, error) { - result := AssignmentsClientListResponse{RawResponse: resp} + result := AssignmentsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentListResult); err != nil { return AssignmentsClientListResponse{}, err } @@ -430,16 +451,32 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign // managementGroupID - The ID of the management group. // options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.ListForManagementGroup // method. -func (client *AssignmentsClient) ListForManagementGroup(managementGroupID string, options *AssignmentsClientListForManagementGroupOptions) *AssignmentsClientListForManagementGroupPager { - return &AssignmentsClientListForManagementGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) +func (client *AssignmentsClient) ListForManagementGroup(managementGroupID string, options *AssignmentsClientListForManagementGroupOptions) *runtime.Pager[AssignmentsClientListForManagementGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[AssignmentsClientListForManagementGroupResponse]{ + More: func(page AssignmentsClientListForManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp AssignmentsClientListForManagementGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.AssignmentListResult.NextLink) + Fetcher: func(ctx context.Context, page *AssignmentsClientListForManagementGroupResponse) (AssignmentsClientListForManagementGroupResponse, 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 AssignmentsClientListForManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AssignmentsClientListForManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AssignmentsClientListForManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listForManagementGroupHandleResponse(resp) }, - } + }) } // listForManagementGroupCreateRequest creates the ListForManagementGroup request. @@ -470,7 +507,7 @@ func (client *AssignmentsClient) listForManagementGroupCreateRequest(ctx context // listForManagementGroupHandleResponse handles the ListForManagementGroup response. func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http.Response) (AssignmentsClientListForManagementGroupResponse, error) { - result := AssignmentsClientListForManagementGroupResponse{RawResponse: resp} + result := AssignmentsClientListForManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentListResult); err != nil { return AssignmentsClientListForManagementGroupResponse{}, err } @@ -507,16 +544,32 @@ func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http // resourceName - The name of the resource. // options - AssignmentsClientListForResourceOptions contains the optional parameters for the AssignmentsClient.ListForResource // method. -func (client *AssignmentsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *AssignmentsClientListForResourceOptions) *AssignmentsClientListForResourcePager { - return &AssignmentsClientListForResourcePager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) +func (client *AssignmentsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *AssignmentsClientListForResourceOptions) *runtime.Pager[AssignmentsClientListForResourceResponse] { + return runtime.NewPager(runtime.PageProcessor[AssignmentsClientListForResourceResponse]{ + More: func(page AssignmentsClientListForResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp AssignmentsClientListForResourceResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.AssignmentListResult.NextLink) + Fetcher: func(ctx context.Context, page *AssignmentsClientListForResourceResponse) (AssignmentsClientListForResourceResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AssignmentsClientListForResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AssignmentsClientListForResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AssignmentsClientListForResourceResponse{}, runtime.NewResponseError(resp) + } + return client.listForResourceHandleResponse(resp) }, - } + }) } // listForResourceCreateRequest creates the ListForResource request. @@ -561,7 +614,7 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex // listForResourceHandleResponse handles the ListForResource response. func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Response) (AssignmentsClientListForResourceResponse, error) { - result := AssignmentsClientListForResourceResponse{RawResponse: resp} + result := AssignmentsClientListForResourceResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentListResult); err != nil { return AssignmentsClientListForResourceResponse{}, err } @@ -583,16 +636,32 @@ func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Respon // resourceGroupName - The name of the resource group that contains policy assignments. // options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.ListForResourceGroup // method. -func (client *AssignmentsClient) ListForResourceGroup(resourceGroupName string, options *AssignmentsClientListForResourceGroupOptions) *AssignmentsClientListForResourceGroupPager { - return &AssignmentsClientListForResourceGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) +func (client *AssignmentsClient) ListForResourceGroup(resourceGroupName string, options *AssignmentsClientListForResourceGroupOptions) *runtime.Pager[AssignmentsClientListForResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[AssignmentsClientListForResourceGroupResponse]{ + More: func(page AssignmentsClientListForResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp AssignmentsClientListForResourceGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.AssignmentListResult.NextLink) + Fetcher: func(ctx context.Context, page *AssignmentsClientListForResourceGroupResponse) (AssignmentsClientListForResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AssignmentsClientListForResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AssignmentsClientListForResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AssignmentsClientListForResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listForResourceGroupHandleResponse(resp) }, - } + }) } // listForResourceGroupCreateRequest creates the ListForResourceGroup request. @@ -627,7 +696,7 @@ func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.C // listForResourceGroupHandleResponse handles the ListForResourceGroup response. func (client *AssignmentsClient) listForResourceGroupHandleResponse(resp *http.Response) (AssignmentsClientListForResourceGroupResponse, error) { - result := AssignmentsClientListForResourceGroupResponse{RawResponse: resp} + result := AssignmentsClientListForResourceGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.AssignmentListResult); err != nil { return AssignmentsClientListForResourceGroupResponse{}, err } @@ -682,7 +751,7 @@ func (client *AssignmentsClient) updateCreateRequest(ctx context.Context, scope // updateHandleResponse handles the Update response. func (client *AssignmentsClient) updateHandleResponse(resp *http.Response) (AssignmentsClientUpdateResponse, error) { - result := AssignmentsClientUpdateResponse{RawResponse: resp} + result := AssignmentsClientUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientUpdateResponse{}, err } @@ -733,7 +802,7 @@ func (client *AssignmentsClient) updateByIDCreateRequest(ctx context.Context, po // updateByIDHandleResponse handles the UpdateByID response. func (client *AssignmentsClient) updateByIDHandleResponse(resp *http.Response) (AssignmentsClientUpdateByIDResponse, error) { - result := AssignmentsClientUpdateByIDResponse{RawResponse: resp} + result := AssignmentsClientUpdateByIDResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil { return AssignmentsClientUpdateByIDResponse{}, err } diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go index b4a958e1e441..d7a5ecae5790 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -10,7 +10,7 @@ package armpolicy const ( moduleName = "armpolicy" - moduleVersion = "v0.3.1" + moduleVersion = "v0.4.0" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to. @@ -31,11 +31,6 @@ func PossibleAliasPathAttributesValues() []AliasPathAttributes { } } -// ToPtr returns a *AliasPathAttributes pointing to the current value. -func (c AliasPathAttributes) ToPtr() *AliasPathAttributes { - return &c -} - // AliasPathTokenType - The type of the token that the alias path is referring to. type AliasPathTokenType string @@ -72,11 +67,6 @@ func PossibleAliasPathTokenTypeValues() []AliasPathTokenType { } } -// ToPtr returns a *AliasPathTokenType pointing to the current value. -func (c AliasPathTokenType) ToPtr() *AliasPathTokenType { - return &c -} - // AliasPatternType - The type of alias pattern type AliasPatternType string @@ -95,11 +85,6 @@ func PossibleAliasPatternTypeValues() []AliasPatternType { } } -// ToPtr returns a *AliasPatternType pointing to the current value. -func (c AliasPatternType) ToPtr() *AliasPatternType { - return &c -} - // AliasType - The type of the alias. type AliasType string @@ -121,11 +106,6 @@ func PossibleAliasTypeValues() []AliasType { } } -// ToPtr returns a *AliasType pointing to the current value. -func (c AliasType) ToPtr() *AliasType { - return &c -} - // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -146,11 +126,6 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// ToPtr returns a *CreatedByType pointing to the current value. -func (c CreatedByType) ToPtr() *CreatedByType { - return &c -} - // EnforcementMode - The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. type EnforcementMode string @@ -169,11 +144,6 @@ func PossibleEnforcementModeValues() []EnforcementMode { } } -// ToPtr returns a *EnforcementMode pointing to the current value. -func (c EnforcementMode) ToPtr() *EnforcementMode { - return &c -} - // ExemptionCategory - The policy exemption category. Possible values are Waiver and Mitigated. type ExemptionCategory string @@ -193,11 +163,6 @@ func PossibleExemptionCategoryValues() []ExemptionCategory { } } -// ToPtr returns a *ExemptionCategory pointing to the current value. -func (c ExemptionCategory) ToPtr() *ExemptionCategory { - return &c -} - // ParameterType - The data type of the parameter. type ParameterType string @@ -224,11 +189,6 @@ func PossibleParameterTypeValues() []ParameterType { } } -// ToPtr returns a *ParameterType pointing to the current value. -func (c ParameterType) ToPtr() *ParameterType { - return &c -} - // PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. type PolicyType string @@ -249,11 +209,6 @@ func PossiblePolicyTypeValues() []PolicyType { } } -// ToPtr returns a *PolicyType pointing to the current value. -func (c PolicyType) ToPtr() *PolicyType { - return &c -} - // ResourceIdentityType - The identity type. This is the only required field when adding a system or user assigned identity // to a resource. type ResourceIdentityType string @@ -276,8 +231,3 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType { ResourceIdentityTypeNone, } } - -// ToPtr returns a *ResourceIdentityType pointing to the current value. -func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { - return &c -} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go index b5f7dcc7ee05..805725df3286 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_datapolicymanifests_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -14,6 +14,7 @@ import ( "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" @@ -31,19 +32,23 @@ type DataPolicyManifestsClient struct { // NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient with the specified values. // credential - used to authorize requests. Usually a credential from azidentity. // options - pass nil to accept the default values. -func NewDataPolicyManifestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *DataPolicyManifestsClient { +func NewDataPolicyManifestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DataPolicyManifestsClient, error) { if options == nil { options = &arm.ClientOptions{} } - ep := options.Endpoint - if len(ep) == 0 { - ep = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.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 := &DataPolicyManifestsClient{ - host: string(ep), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + host: ep, + pl: pl, } - return client + return client, nil } // GetByPolicyMode - This operation retrieves the data policy manifest with the given policy mode. @@ -86,7 +91,7 @@ func (client *DataPolicyManifestsClient) getByPolicyModeCreateRequest(ctx contex // getByPolicyModeHandleResponse handles the GetByPolicyMode response. func (client *DataPolicyManifestsClient) getByPolicyModeHandleResponse(resp *http.Response) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - result := DataPolicyManifestsClientGetByPolicyModeResponse{RawResponse: resp} + result := DataPolicyManifestsClientGetByPolicyModeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifest); err != nil { return DataPolicyManifestsClientGetByPolicyModeResponse{}, err } @@ -101,16 +106,32 @@ func (client *DataPolicyManifestsClient) getByPolicyModeHandleResponse(resp *htt // If the operation fails it returns an *azcore.ResponseError type. // options - DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.List // method. -func (client *DataPolicyManifestsClient) List(options *DataPolicyManifestsClientListOptions) *DataPolicyManifestsClientListPager { - return &DataPolicyManifestsClientListPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) +func (client *DataPolicyManifestsClient) List(options *DataPolicyManifestsClientListOptions) *runtime.Pager[DataPolicyManifestsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[DataPolicyManifestsClientListResponse]{ + More: func(page DataPolicyManifestsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp DataPolicyManifestsClientListResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.DataPolicyManifestListResult.NextLink) + Fetcher: func(ctx context.Context, page *DataPolicyManifestsClientListResponse) (DataPolicyManifestsClientListResponse, 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 DataPolicyManifestsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DataPolicyManifestsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DataPolicyManifestsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) }, - } + }) } // listCreateRequest creates the List request. @@ -134,7 +155,7 @@ func (client *DataPolicyManifestsClient) listCreateRequest(ctx context.Context, // listHandleResponse handles the List response. func (client *DataPolicyManifestsClient) listHandleResponse(resp *http.Response) (DataPolicyManifestsClientListResponse, error) { - result := DataPolicyManifestsClientListResponse{RawResponse: resp} + result := DataPolicyManifestsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifestListResult); err != nil { return DataPolicyManifestsClientListResponse{}, err } diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go index e618297ca84d..5598d302cfa5 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_definitions_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -14,6 +14,7 @@ import ( "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" @@ -34,20 +35,24 @@ type DefinitionsClient struct { // 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 NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DefinitionsClient { +func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionsClient, error) { if options == nil { options = &arm.ClientOptions{} } - ep := options.Endpoint - if len(ep) == 0 { - ep = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.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 := &DefinitionsClient{ subscriptionID: subscriptionID, - host: string(ep), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + host: ep, + pl: pl, } - return client + return client, nil } // CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. @@ -95,7 +100,7 @@ func (client *DefinitionsClient) createOrUpdateCreateRequest(ctx context.Context // createOrUpdateHandleResponse handles the CreateOrUpdate response. func (client *DefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (DefinitionsClientCreateOrUpdateResponse, error) { - result := DefinitionsClientCreateOrUpdateResponse{RawResponse: resp} + result := DefinitionsClientCreateOrUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Definition); err != nil { return DefinitionsClientCreateOrUpdateResponse{}, err } @@ -149,7 +154,7 @@ func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ct // createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. func (client *DefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (DefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { - result := DefinitionsClientCreateOrUpdateAtManagementGroupResponse{RawResponse: resp} + result := DefinitionsClientCreateOrUpdateAtManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Definition); err != nil { return DefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } @@ -172,7 +177,7 @@ func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionNam if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { return DefinitionsClientDeleteResponse{}, runtime.NewResponseError(resp) } - return DefinitionsClientDeleteResponse{RawResponse: resp}, nil + return DefinitionsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. @@ -215,7 +220,7 @@ func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, po if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { return DefinitionsClientDeleteAtManagementGroupResponse{}, runtime.NewResponseError(resp) } - return DefinitionsClientDeleteAtManagementGroupResponse{RawResponse: resp}, nil + return DefinitionsClientDeleteAtManagementGroupResponse{}, nil } // deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. @@ -283,7 +288,7 @@ func (client *DefinitionsClient) getCreateRequest(ctx context.Context, policyDef // getHandleResponse handles the Get response. func (client *DefinitionsClient) getHandleResponse(resp *http.Response) (DefinitionsClientGetResponse, error) { - result := DefinitionsClientGetResponse{RawResponse: resp} + result := DefinitionsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Definition); err != nil { return DefinitionsClientGetResponse{}, err } @@ -335,7 +340,7 @@ func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.C // getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. func (client *DefinitionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (DefinitionsClientGetAtManagementGroupResponse, error) { - result := DefinitionsClientGetAtManagementGroupResponse{RawResponse: resp} + result := DefinitionsClientGetAtManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Definition); err != nil { return DefinitionsClientGetAtManagementGroupResponse{}, err } @@ -381,7 +386,7 @@ func (client *DefinitionsClient) getBuiltInCreateRequest(ctx context.Context, po // getBuiltInHandleResponse handles the GetBuiltIn response. func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) (DefinitionsClientGetBuiltInResponse, error) { - result := DefinitionsClientGetBuiltInResponse{RawResponse: resp} + result := DefinitionsClientGetBuiltInResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Definition); err != nil { return DefinitionsClientGetBuiltInResponse{}, err } @@ -399,16 +404,32 @@ func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) ( // {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. // options - DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.List method. -func (client *DefinitionsClient) List(options *DefinitionsClientListOptions) *DefinitionsClientListPager { - return &DefinitionsClientListPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) +func (client *DefinitionsClient) List(options *DefinitionsClientListOptions) *runtime.Pager[DefinitionsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[DefinitionsClientListResponse]{ + More: func(page DefinitionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp DefinitionsClientListResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.DefinitionListResult.NextLink) + Fetcher: func(ctx context.Context, page *DefinitionsClientListResponse) (DefinitionsClientListResponse, 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 DefinitionsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DefinitionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DefinitionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) }, - } + }) } // listCreateRequest creates the List request. @@ -439,7 +460,7 @@ func (client *DefinitionsClient) listCreateRequest(ctx context.Context, options // listHandleResponse handles the List response. func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (DefinitionsClientListResponse, error) { - result := DefinitionsClientListResponse{RawResponse: resp} + result := DefinitionsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionListResult); err != nil { return DefinitionsClientListResponse{}, err } @@ -453,16 +474,32 @@ func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (Defini // only includes all built-in policy definitions whose category match the {value}. // If the operation fails it returns an *azcore.ResponseError type. // options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.ListBuiltIn method. -func (client *DefinitionsClient) ListBuiltIn(options *DefinitionsClientListBuiltInOptions) *DefinitionsClientListBuiltInPager { - return &DefinitionsClientListBuiltInPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listBuiltInCreateRequest(ctx, options) +func (client *DefinitionsClient) ListBuiltIn(options *DefinitionsClientListBuiltInOptions) *runtime.Pager[DefinitionsClientListBuiltInResponse] { + return runtime.NewPager(runtime.PageProcessor[DefinitionsClientListBuiltInResponse]{ + More: func(page DefinitionsClientListBuiltInResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp DefinitionsClientListBuiltInResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.DefinitionListResult.NextLink) + Fetcher: func(ctx context.Context, page *DefinitionsClientListBuiltInResponse) (DefinitionsClientListBuiltInResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBuiltInCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DefinitionsClientListBuiltInResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DefinitionsClientListBuiltInResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DefinitionsClientListBuiltInResponse{}, runtime.NewResponseError(resp) + } + return client.listBuiltInHandleResponse(resp) }, - } + }) } // listBuiltInCreateRequest creates the ListBuiltIn request. @@ -489,7 +526,7 @@ func (client *DefinitionsClient) listBuiltInCreateRequest(ctx context.Context, o // listBuiltInHandleResponse handles the ListBuiltIn response. func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) (DefinitionsClientListBuiltInResponse, error) { - result := DefinitionsClientListBuiltInResponse{RawResponse: resp} + result := DefinitionsClientListBuiltInResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionListResult); err != nil { return DefinitionsClientListBuiltInResponse{}, err } @@ -510,16 +547,32 @@ func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) // managementGroupID - The ID of the management group. // options - DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.ListByManagementGroup // method. -func (client *DefinitionsClient) ListByManagementGroup(managementGroupID string, options *DefinitionsClientListByManagementGroupOptions) *DefinitionsClientListByManagementGroupPager { - return &DefinitionsClientListByManagementGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listByManagementGroupCreateRequest(ctx, managementGroupID, options) +func (client *DefinitionsClient) ListByManagementGroup(managementGroupID string, options *DefinitionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionsClientListByManagementGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[DefinitionsClientListByManagementGroupResponse]{ + More: func(page DefinitionsClientListByManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp DefinitionsClientListByManagementGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.DefinitionListResult.NextLink) + Fetcher: func(ctx context.Context, page *DefinitionsClientListByManagementGroupResponse) (DefinitionsClientListByManagementGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByManagementGroupCreateRequest(ctx, managementGroupID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DefinitionsClientListByManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DefinitionsClientListByManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DefinitionsClientListByManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByManagementGroupHandleResponse(resp) }, - } + }) } // listByManagementGroupCreateRequest creates the ListByManagementGroup request. @@ -550,7 +603,7 @@ func (client *DefinitionsClient) listByManagementGroupCreateRequest(ctx context. // listByManagementGroupHandleResponse handles the ListByManagementGroup response. func (client *DefinitionsClient) listByManagementGroupHandleResponse(resp *http.Response) (DefinitionsClientListByManagementGroupResponse, error) { - result := DefinitionsClientListByManagementGroupResponse{RawResponse: resp} + result := DefinitionsClientListByManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionListResult); err != nil { return DefinitionsClientListByManagementGroupResponse{}, err } diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go index 926a297138b6..7e0a27026063 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_exemptions_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -14,6 +14,7 @@ import ( "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" @@ -33,20 +34,24 @@ type ExemptionsClient struct { // 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 NewExemptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ExemptionsClient { +func NewExemptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExemptionsClient, error) { if options == nil { options = &arm.ClientOptions{} } - ep := options.Endpoint - if len(ep) == 0 { - ep = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.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 := &ExemptionsClient{ subscriptionID: subscriptionID, - host: string(ep), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + host: ep, + pl: pl, } - return client + return client, nil } // CreateOrUpdate - This operation creates or updates a policy exemption with the given scope and name. Policy exemptions @@ -99,7 +104,7 @@ func (client *ExemptionsClient) createOrUpdateCreateRequest(ctx context.Context, // createOrUpdateHandleResponse handles the CreateOrUpdate response. func (client *ExemptionsClient) createOrUpdateHandleResponse(resp *http.Response) (ExemptionsClientCreateOrUpdateResponse, error) { - result := ExemptionsClientCreateOrUpdateResponse{RawResponse: resp} + result := ExemptionsClientCreateOrUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { return ExemptionsClientCreateOrUpdateResponse{}, err } @@ -129,7 +134,7 @@ func (client *ExemptionsClient) Delete(ctx context.Context, scope string, policy if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { return ExemptionsClientDeleteResponse{}, runtime.NewResponseError(resp) } - return ExemptionsClientDeleteResponse{RawResponse: resp}, nil + return ExemptionsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. @@ -196,7 +201,7 @@ func (client *ExemptionsClient) getCreateRequest(ctx context.Context, scope stri // getHandleResponse handles the Get response. func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (ExemptionsClientGetResponse, error) { - result := ExemptionsClientGetResponse{RawResponse: resp} + result := ExemptionsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { return ExemptionsClientGetResponse{}, err } @@ -211,16 +216,32 @@ func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (Exemptio // the subscription. // If the operation fails it returns an *azcore.ResponseError type. // options - ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.List method. -func (client *ExemptionsClient) List(options *ExemptionsClientListOptions) *ExemptionsClientListPager { - return &ExemptionsClientListPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) +func (client *ExemptionsClient) List(options *ExemptionsClientListOptions) *runtime.Pager[ExemptionsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[ExemptionsClientListResponse]{ + More: func(page ExemptionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp ExemptionsClientListResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.ExemptionListResult.NextLink) + Fetcher: func(ctx context.Context, page *ExemptionsClientListResponse) (ExemptionsClientListResponse, 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 ExemptionsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExemptionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExemptionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) }, - } + }) } // listCreateRequest creates the List request. @@ -248,7 +269,7 @@ func (client *ExemptionsClient) listCreateRequest(ctx context.Context, options * // listHandleResponse handles the List response. func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (ExemptionsClientListResponse, error) { - result := ExemptionsClientListResponse{RawResponse: resp} + result := ExemptionsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { return ExemptionsClientListResponse{}, err } @@ -264,16 +285,32 @@ func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (Exempti // managementGroupID - The ID of the management group. // options - ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.ListForManagementGroup // method. -func (client *ExemptionsClient) ListForManagementGroup(managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) *ExemptionsClientListForManagementGroupPager { - return &ExemptionsClientListForManagementGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) +func (client *ExemptionsClient) ListForManagementGroup(managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) *runtime.Pager[ExemptionsClientListForManagementGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[ExemptionsClientListForManagementGroupResponse]{ + More: func(page ExemptionsClientListForManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp ExemptionsClientListForManagementGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.ExemptionListResult.NextLink) + Fetcher: func(ctx context.Context, page *ExemptionsClientListForManagementGroupResponse) (ExemptionsClientListForManagementGroupResponse, 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 ExemptionsClientListForManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExemptionsClientListForManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExemptionsClientListForManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listForManagementGroupHandleResponse(resp) }, - } + }) } // listForManagementGroupCreateRequest creates the ListForManagementGroup request. @@ -301,7 +338,7 @@ func (client *ExemptionsClient) listForManagementGroupCreateRequest(ctx context. // listForManagementGroupHandleResponse handles the ListForManagementGroup response. func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http.Response) (ExemptionsClientListForManagementGroupResponse, error) { - result := ExemptionsClientListForManagementGroupResponse{RawResponse: resp} + result := ExemptionsClientListForManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { return ExemptionsClientListForManagementGroupResponse{}, err } @@ -333,16 +370,32 @@ func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http. // resourceName - The name of the resource. // options - ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.ListForResource // method. -func (client *ExemptionsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) *ExemptionsClientListForResourcePager { - return &ExemptionsClientListForResourcePager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) +func (client *ExemptionsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) *runtime.Pager[ExemptionsClientListForResourceResponse] { + return runtime.NewPager(runtime.PageProcessor[ExemptionsClientListForResourceResponse]{ + More: func(page ExemptionsClientListForResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp ExemptionsClientListForResourceResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.ExemptionListResult.NextLink) + Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceResponse) (ExemptionsClientListForResourceResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ExemptionsClientListForResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExemptionsClientListForResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExemptionsClientListForResourceResponse{}, runtime.NewResponseError(resp) + } + return client.listForResourceHandleResponse(resp) }, - } + }) } // listForResourceCreateRequest creates the ListForResource request. @@ -384,7 +437,7 @@ func (client *ExemptionsClient) listForResourceCreateRequest(ctx context.Context // listForResourceHandleResponse handles the ListForResource response. func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Response) (ExemptionsClientListForResourceResponse, error) { - result := ExemptionsClientListForResourceResponse{RawResponse: resp} + result := ExemptionsClientListForResourceResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { return ExemptionsClientListForResourceResponse{}, err } @@ -401,16 +454,32 @@ func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Respons // resourceGroupName - The name of the resource group containing the resource. // options - ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.ListForResourceGroup // method. -func (client *ExemptionsClient) ListForResourceGroup(resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) *ExemptionsClientListForResourceGroupPager { - return &ExemptionsClientListForResourceGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) +func (client *ExemptionsClient) ListForResourceGroup(resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) *runtime.Pager[ExemptionsClientListForResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[ExemptionsClientListForResourceGroupResponse]{ + More: func(page ExemptionsClientListForResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp ExemptionsClientListForResourceGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.ExemptionListResult.NextLink) + Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceGroupResponse) (ExemptionsClientListForResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ExemptionsClientListForResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExemptionsClientListForResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExemptionsClientListForResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listForResourceGroupHandleResponse(resp) }, - } + }) } // listForResourceGroupCreateRequest creates the ListForResourceGroup request. @@ -442,7 +511,7 @@ func (client *ExemptionsClient) listForResourceGroupCreateRequest(ctx context.Co // listForResourceGroupHandleResponse handles the ListForResourceGroup response. func (client *ExemptionsClient) listForResourceGroupHandleResponse(resp *http.Response) (ExemptionsClientListForResourceGroupResponse, error) { - result := ExemptionsClientListForResourceGroupResponse{RawResponse: resp} + result := ExemptionsClientListForResourceGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { return ExemptionsClientListForResourceGroupResponse{}, err } diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_models.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_models.go index 926d1e7bbc85..e80f5c9b341b 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_models.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_models.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -8,12 +8,7 @@ package armpolicy -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "time" -) +import "time" // Alias - The alias type. type Alias struct { @@ -36,18 +31,6 @@ type Alias struct { DefaultMetadata *AliasPathMetadata `json:"defaultMetadata,omitempty" azure:"ro"` } -// 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) -} - // AliasPath - The type of the paths for alias. type AliasPath struct { // The API versions. @@ -63,16 +46,6 @@ type AliasPath struct { Metadata *AliasPathMetadata `json:"metadata,omitempty" azure:"ro"` } -// 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) -} - type AliasPathMetadata struct { // READ-ONLY; The attributes of the token that the alias path is referring to. Attributes *AliasPathAttributes `json:"attributes,omitempty" azure:"ro"` @@ -126,14 +99,6 @@ type AssignmentListResult struct { Value []*Assignment `json:"value,omitempty"` } -// 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) -} - // AssignmentProperties - The policy assignment properties. type AssignmentProperties struct { // This message will be part of response in case of policy violation. @@ -164,21 +129,6 @@ type AssignmentProperties struct { Scope *string `json:"scope,omitempty" azure:"ro"` } -// 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) -} - type AssignmentUpdate struct { // The managed identity associated with the policy assignment. Identity *Identity `json:"identity,omitempty"` @@ -187,14 +137,6 @@ type AssignmentUpdate struct { Location *string `json:"location,omitempty"` } -// 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) -} - // AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method. type AssignmentsClientCreateByIDOptions struct { // placeholder for future optional parameters @@ -293,6 +235,13 @@ 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. @@ -319,16 +268,6 @@ type DataManifestCustomResourceFunctionDefinition struct { Name *string `json:"name,omitempty"` } -// 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) -} - // DataManifestResourceFunctionsDefinition - The resource functions supported by a manifest type DataManifestResourceFunctionsDefinition struct { // An array of data manifest custom resource definition. @@ -338,14 +277,6 @@ type DataManifestResourceFunctionsDefinition struct { Standard []*string `json:"standard,omitempty"` } -// 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) -} - // DataPolicyManifest - The data policy manifest. type DataPolicyManifest struct { // The data policy manifest properties. @@ -370,14 +301,6 @@ type DataPolicyManifestListResult struct { Value []*DataPolicyManifest `json:"value,omitempty"` } -// 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) -} - // DataPolicyManifestProperties - The properties of the data policy manifest. type DataPolicyManifestProperties struct { // The effect definition. @@ -402,19 +325,6 @@ type DataPolicyManifestProperties struct { ResourceTypeAliases []*ResourceTypeAliases `json:"resourceTypeAliases,omitempty"` } -// 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) -} - // DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode // method. type DataPolicyManifestsClientGetByPolicyModeOptions struct { @@ -474,14 +384,6 @@ type DefinitionListResult struct { Value []*Definition `json:"value,omitempty"` } -// 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) -} - // DefinitionProperties - The policy definition properties. type DefinitionProperties struct { // The policy definition description. @@ -506,19 +408,6 @@ type DefinitionProperties struct { PolicyType *PolicyType `json:"policyType,omitempty"` } -// 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) -} - // DefinitionReference - The policy definition reference. type DefinitionReference struct { // REQUIRED; The ID of the policy definition or policy set definition. @@ -534,16 +423,6 @@ type DefinitionReference struct { PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` } -// 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) -} - // DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup // method. type DefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -625,6 +504,34 @@ type DefinitionsClientListOptions struct { Top *int32 } +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.) +type ErrorResponse struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorResponse `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + // Exemption - The policy exemption. type Exemption struct { // REQUIRED; Properties for the policy exemption. @@ -652,14 +559,6 @@ type ExemptionListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// 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) -} - // ExemptionProperties - The policy exemption properties. type ExemptionProperties struct { // REQUIRED; The policy exemption category. Possible values are Waiver and Mitigated. @@ -684,57 +583,6 @@ type ExemptionProperties struct { PolicyDefinitionReferenceIDs []*string `json:"policyDefinitionReferenceIds,omitempty"` } -// 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 err - } - for key, val := range rawMsg { - var err error - switch key { - case "description": - err = unpopulate(val, &e.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, &e.DisplayName) - delete(rawMsg, key) - case "exemptionCategory": - err = unpopulate(val, &e.ExemptionCategory) - delete(rawMsg, key) - case "expiresOn": - err = unpopulateTimeRFC3339(val, &e.ExpiresOn) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, &e.Metadata) - delete(rawMsg, key) - case "policyAssignmentId": - err = unpopulate(val, &e.PolicyAssignmentID) - delete(rawMsg, key) - case "policyDefinitionReferenceIds": - err = unpopulate(val, &e.PolicyDefinitionReferenceIDs) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - // ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate method. type ExemptionsClientCreateOrUpdateOptions struct { // placeholder for future optional parameters @@ -834,16 +682,6 @@ type Identity struct { TenantID *string `json:"tenantId,omitempty" azure:"ro"` } -// 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) -} - // NonComplianceMessage - A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' // error messages and on resource's non-compliant compliance results. type NonComplianceMessage struct { @@ -872,16 +710,6 @@ type ParameterDefinitionsValue struct { Type *ParameterType `json:"type,omitempty"` } -// 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) -} - // ParameterDefinitionsValueMetadata - General metadata for the parameter. type ParameterDefinitionsValueMetadata struct { // OPTIONAL; Contains additional key/value pairs not defined in the schema. @@ -903,60 +731,6 @@ type ParameterDefinitionsValueMetadata struct { StrongType *string `json:"strongType,omitempty"` } -// 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 err - } - for key, val := range rawMsg { - var err error - switch key { - case "assignPermissions": - err = unpopulate(val, &p.AssignPermissions) - delete(rawMsg, key) - case "description": - err = unpopulate(val, &p.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, &p.DisplayName) - delete(rawMsg, key) - case "strongType": - err = unpopulate(val, &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 err - } - } - return nil -} - // ParameterValuesValue - The value of a parameter. type ParameterValuesValue struct { // The value of the parameter. @@ -972,14 +746,6 @@ type ResourceTypeAliases struct { ResourceType *string `json:"resourceType,omitempty"` } -// 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) -} - // SetDefinition - The policy set definition. type SetDefinition struct { // The policy definition properties. @@ -1007,14 +773,6 @@ type SetDefinitionListResult struct { Value []*SetDefinition `json:"value,omitempty"` } -// 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) -} - // SetDefinitionProperties - The policy set definition properties. type SetDefinitionProperties struct { // REQUIRED; An array of policy definition references. @@ -1039,19 +797,6 @@ type SetDefinitionProperties struct { PolicyType *PolicyType `json:"policyType,omitempty"` } -// 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) -} - // SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup // method. type SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -1155,53 +900,6 @@ type SystemData struct { LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` } -// 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 err - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - type UserAssignedIdentitiesValue struct { // READ-ONLY; The client id of user assigned identity. ClientID *string `json:"clientId,omitempty" azure:"ro"` @@ -1209,20 +907,3 @@ type UserAssignedIdentitiesValue struct { // READ-ONLY; The principal id of user assigned identity. PrincipalID *string `json:"principalId,omitempty" azure:"ro"` } - -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, v interface{}) error { - if data == nil { - return nil - } - return json.Unmarshal(data, v) -} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go new file mode 100644 index 000000000000..10023aca2f83 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_models_serde.go @@ -0,0 +1,375 @@ +//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" + "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) +} + +// 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) +} + +// 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) +} + +// 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 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) +} + +// 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) +} + +// 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) +} + +// 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) +} + +// 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) +} + +// 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 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) +} + +// 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) +} + +// 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, &e.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &e.DisplayName) + delete(rawMsg, key) + case "exemptionCategory": + err = unpopulate(val, &e.ExemptionCategory) + delete(rawMsg, key) + case "expiresOn": + err = unpopulateTimeRFC3339(val, &e.ExpiresOn) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, &e.Metadata) + delete(rawMsg, key) + case "policyAssignmentId": + err = unpopulate(val, &e.PolicyAssignmentID) + delete(rawMsg, key) + case "policyDefinitionReferenceIds": + err = unpopulate(val, &e.PolicyDefinitionReferenceIDs) + delete(rawMsg, key) + } + if err != nil { + return 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "assignPermissions": + err = unpopulate(val, &p.AssignPermissions) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &p.DisplayName) + delete(rawMsg, key) + case "strongType": + err = unpopulate(val, &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 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) +} + +// 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) +} + +// 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return 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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_pagers.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_pagers.go deleted file mode 100644 index da9f15b9c2aa..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_pagers.go +++ /dev/null @@ -1,827 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// 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 ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "reflect" -) - -// AssignmentsClientListForManagementGroupPager provides operations for iterating over paged responses. -type AssignmentsClientListForManagementGroupPager struct { - client *AssignmentsClient - current AssignmentsClientListForManagementGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, AssignmentsClientListForManagementGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *AssignmentsClientListForManagementGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *AssignmentsClientListForManagementGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.AssignmentListResult.NextLink == nil || len(*p.current.AssignmentListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listForManagementGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current AssignmentsClientListForManagementGroupResponse page. -func (p *AssignmentsClientListForManagementGroupPager) PageResponse() AssignmentsClientListForManagementGroupResponse { - return p.current -} - -// AssignmentsClientListForResourceGroupPager provides operations for iterating over paged responses. -type AssignmentsClientListForResourceGroupPager struct { - client *AssignmentsClient - current AssignmentsClientListForResourceGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, AssignmentsClientListForResourceGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *AssignmentsClientListForResourceGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *AssignmentsClientListForResourceGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.AssignmentListResult.NextLink == nil || len(*p.current.AssignmentListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listForResourceGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current AssignmentsClientListForResourceGroupResponse page. -func (p *AssignmentsClientListForResourceGroupPager) PageResponse() AssignmentsClientListForResourceGroupResponse { - return p.current -} - -// AssignmentsClientListForResourcePager provides operations for iterating over paged responses. -type AssignmentsClientListForResourcePager struct { - client *AssignmentsClient - current AssignmentsClientListForResourceResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, AssignmentsClientListForResourceResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *AssignmentsClientListForResourcePager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *AssignmentsClientListForResourcePager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.AssignmentListResult.NextLink == nil || len(*p.current.AssignmentListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listForResourceHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current AssignmentsClientListForResourceResponse page. -func (p *AssignmentsClientListForResourcePager) PageResponse() AssignmentsClientListForResourceResponse { - return p.current -} - -// AssignmentsClientListPager provides operations for iterating over paged responses. -type AssignmentsClientListPager struct { - client *AssignmentsClient - current AssignmentsClientListResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, AssignmentsClientListResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *AssignmentsClientListPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *AssignmentsClientListPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.AssignmentListResult.NextLink == nil || len(*p.current.AssignmentListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current AssignmentsClientListResponse page. -func (p *AssignmentsClientListPager) PageResponse() AssignmentsClientListResponse { - return p.current -} - -// DataPolicyManifestsClientListPager provides operations for iterating over paged responses. -type DataPolicyManifestsClientListPager struct { - client *DataPolicyManifestsClient - current DataPolicyManifestsClientListResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, DataPolicyManifestsClientListResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *DataPolicyManifestsClientListPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *DataPolicyManifestsClientListPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.DataPolicyManifestListResult.NextLink == nil || len(*p.current.DataPolicyManifestListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current DataPolicyManifestsClientListResponse page. -func (p *DataPolicyManifestsClientListPager) PageResponse() DataPolicyManifestsClientListResponse { - return p.current -} - -// DefinitionsClientListBuiltInPager provides operations for iterating over paged responses. -type DefinitionsClientListBuiltInPager struct { - client *DefinitionsClient - current DefinitionsClientListBuiltInResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, DefinitionsClientListBuiltInResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *DefinitionsClientListBuiltInPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *DefinitionsClientListBuiltInPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.DefinitionListResult.NextLink == nil || len(*p.current.DefinitionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listBuiltInHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current DefinitionsClientListBuiltInResponse page. -func (p *DefinitionsClientListBuiltInPager) PageResponse() DefinitionsClientListBuiltInResponse { - return p.current -} - -// DefinitionsClientListByManagementGroupPager provides operations for iterating over paged responses. -type DefinitionsClientListByManagementGroupPager struct { - client *DefinitionsClient - current DefinitionsClientListByManagementGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, DefinitionsClientListByManagementGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *DefinitionsClientListByManagementGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *DefinitionsClientListByManagementGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.DefinitionListResult.NextLink == nil || len(*p.current.DefinitionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listByManagementGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current DefinitionsClientListByManagementGroupResponse page. -func (p *DefinitionsClientListByManagementGroupPager) PageResponse() DefinitionsClientListByManagementGroupResponse { - return p.current -} - -// DefinitionsClientListPager provides operations for iterating over paged responses. -type DefinitionsClientListPager struct { - client *DefinitionsClient - current DefinitionsClientListResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, DefinitionsClientListResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *DefinitionsClientListPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *DefinitionsClientListPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.DefinitionListResult.NextLink == nil || len(*p.current.DefinitionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current DefinitionsClientListResponse page. -func (p *DefinitionsClientListPager) PageResponse() DefinitionsClientListResponse { - return p.current -} - -// ExemptionsClientListForManagementGroupPager provides operations for iterating over paged responses. -type ExemptionsClientListForManagementGroupPager struct { - client *ExemptionsClient - current ExemptionsClientListForManagementGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, ExemptionsClientListForManagementGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *ExemptionsClientListForManagementGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *ExemptionsClientListForManagementGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ExemptionListResult.NextLink == nil || len(*p.current.ExemptionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listForManagementGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current ExemptionsClientListForManagementGroupResponse page. -func (p *ExemptionsClientListForManagementGroupPager) PageResponse() ExemptionsClientListForManagementGroupResponse { - return p.current -} - -// ExemptionsClientListForResourceGroupPager provides operations for iterating over paged responses. -type ExemptionsClientListForResourceGroupPager struct { - client *ExemptionsClient - current ExemptionsClientListForResourceGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, ExemptionsClientListForResourceGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *ExemptionsClientListForResourceGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *ExemptionsClientListForResourceGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ExemptionListResult.NextLink == nil || len(*p.current.ExemptionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listForResourceGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current ExemptionsClientListForResourceGroupResponse page. -func (p *ExemptionsClientListForResourceGroupPager) PageResponse() ExemptionsClientListForResourceGroupResponse { - return p.current -} - -// ExemptionsClientListForResourcePager provides operations for iterating over paged responses. -type ExemptionsClientListForResourcePager struct { - client *ExemptionsClient - current ExemptionsClientListForResourceResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, ExemptionsClientListForResourceResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *ExemptionsClientListForResourcePager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *ExemptionsClientListForResourcePager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ExemptionListResult.NextLink == nil || len(*p.current.ExemptionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listForResourceHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current ExemptionsClientListForResourceResponse page. -func (p *ExemptionsClientListForResourcePager) PageResponse() ExemptionsClientListForResourceResponse { - return p.current -} - -// ExemptionsClientListPager provides operations for iterating over paged responses. -type ExemptionsClientListPager struct { - client *ExemptionsClient - current ExemptionsClientListResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, ExemptionsClientListResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *ExemptionsClientListPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *ExemptionsClientListPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ExemptionListResult.NextLink == nil || len(*p.current.ExemptionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current ExemptionsClientListResponse page. -func (p *ExemptionsClientListPager) PageResponse() ExemptionsClientListResponse { - return p.current -} - -// SetDefinitionsClientListBuiltInPager provides operations for iterating over paged responses. -type SetDefinitionsClientListBuiltInPager struct { - client *SetDefinitionsClient - current SetDefinitionsClientListBuiltInResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, SetDefinitionsClientListBuiltInResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *SetDefinitionsClientListBuiltInPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *SetDefinitionsClientListBuiltInPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.SetDefinitionListResult.NextLink == nil || len(*p.current.SetDefinitionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listBuiltInHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current SetDefinitionsClientListBuiltInResponse page. -func (p *SetDefinitionsClientListBuiltInPager) PageResponse() SetDefinitionsClientListBuiltInResponse { - return p.current -} - -// SetDefinitionsClientListByManagementGroupPager provides operations for iterating over paged responses. -type SetDefinitionsClientListByManagementGroupPager struct { - client *SetDefinitionsClient - current SetDefinitionsClientListByManagementGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, SetDefinitionsClientListByManagementGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *SetDefinitionsClientListByManagementGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *SetDefinitionsClientListByManagementGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.SetDefinitionListResult.NextLink == nil || len(*p.current.SetDefinitionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listByManagementGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current SetDefinitionsClientListByManagementGroupResponse page. -func (p *SetDefinitionsClientListByManagementGroupPager) PageResponse() SetDefinitionsClientListByManagementGroupResponse { - return p.current -} - -// SetDefinitionsClientListPager provides operations for iterating over paged responses. -type SetDefinitionsClientListPager struct { - client *SetDefinitionsClient - current SetDefinitionsClientListResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, SetDefinitionsClientListResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *SetDefinitionsClientListPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *SetDefinitionsClientListPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.SetDefinitionListResult.NextLink == nil || len(*p.current.SetDefinitionListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current SetDefinitionsClientListResponse page. -func (p *SetDefinitionsClientListPager) PageResponse() SetDefinitionsClientListResponse { - return p.current -} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go index bef8b5f2a11a..1c2641b09b03 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_response_types.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -8,466 +8,207 @@ package armpolicy -import "net/http" - // AssignmentsClientCreateByIDResponse contains the response from method AssignmentsClient.CreateByID. type AssignmentsClientCreateByIDResponse struct { - AssignmentsClientCreateByIDResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientCreateByIDResult contains the result from method AssignmentsClient.CreateByID. -type AssignmentsClientCreateByIDResult struct { Assignment } // AssignmentsClientCreateResponse contains the response from method AssignmentsClient.Create. type AssignmentsClientCreateResponse struct { - AssignmentsClientCreateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientCreateResult contains the result from method AssignmentsClient.Create. -type AssignmentsClientCreateResult struct { Assignment } // AssignmentsClientDeleteByIDResponse contains the response from method AssignmentsClient.DeleteByID. type AssignmentsClientDeleteByIDResponse struct { - AssignmentsClientDeleteByIDResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientDeleteByIDResult contains the result from method AssignmentsClient.DeleteByID. -type AssignmentsClientDeleteByIDResult struct { Assignment } // AssignmentsClientDeleteResponse contains the response from method AssignmentsClient.Delete. type AssignmentsClientDeleteResponse struct { - AssignmentsClientDeleteResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientDeleteResult contains the result from method AssignmentsClient.Delete. -type AssignmentsClientDeleteResult struct { Assignment } // AssignmentsClientGetByIDResponse contains the response from method AssignmentsClient.GetByID. type AssignmentsClientGetByIDResponse struct { - AssignmentsClientGetByIDResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientGetByIDResult contains the result from method AssignmentsClient.GetByID. -type AssignmentsClientGetByIDResult struct { Assignment } // AssignmentsClientGetResponse contains the response from method AssignmentsClient.Get. type AssignmentsClientGetResponse struct { - AssignmentsClientGetResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientGetResult contains the result from method AssignmentsClient.Get. -type AssignmentsClientGetResult struct { Assignment } // AssignmentsClientListForManagementGroupResponse contains the response from method AssignmentsClient.ListForManagementGroup. type AssignmentsClientListForManagementGroupResponse struct { - AssignmentsClientListForManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientListForManagementGroupResult contains the result from method AssignmentsClient.ListForManagementGroup. -type AssignmentsClientListForManagementGroupResult struct { AssignmentListResult } // AssignmentsClientListForResourceGroupResponse contains the response from method AssignmentsClient.ListForResourceGroup. type AssignmentsClientListForResourceGroupResponse struct { - AssignmentsClientListForResourceGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientListForResourceGroupResult contains the result from method AssignmentsClient.ListForResourceGroup. -type AssignmentsClientListForResourceGroupResult struct { AssignmentListResult } // AssignmentsClientListForResourceResponse contains the response from method AssignmentsClient.ListForResource. type AssignmentsClientListForResourceResponse struct { - AssignmentsClientListForResourceResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientListForResourceResult contains the result from method AssignmentsClient.ListForResource. -type AssignmentsClientListForResourceResult struct { AssignmentListResult } // AssignmentsClientListResponse contains the response from method AssignmentsClient.List. type AssignmentsClientListResponse struct { - AssignmentsClientListResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientListResult contains the result from method AssignmentsClient.List. -type AssignmentsClientListResult struct { AssignmentListResult } // AssignmentsClientUpdateByIDResponse contains the response from method AssignmentsClient.UpdateByID. type AssignmentsClientUpdateByIDResponse struct { - AssignmentsClientUpdateByIDResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientUpdateByIDResult contains the result from method AssignmentsClient.UpdateByID. -type AssignmentsClientUpdateByIDResult struct { Assignment } // AssignmentsClientUpdateResponse contains the response from method AssignmentsClient.Update. type AssignmentsClientUpdateResponse struct { - AssignmentsClientUpdateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// AssignmentsClientUpdateResult contains the result from method AssignmentsClient.Update. -type AssignmentsClientUpdateResult struct { Assignment } // DataPolicyManifestsClientGetByPolicyModeResponse contains the response from method DataPolicyManifestsClient.GetByPolicyMode. type DataPolicyManifestsClientGetByPolicyModeResponse struct { - DataPolicyManifestsClientGetByPolicyModeResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DataPolicyManifestsClientGetByPolicyModeResult contains the result from method DataPolicyManifestsClient.GetByPolicyMode. -type DataPolicyManifestsClientGetByPolicyModeResult struct { DataPolicyManifest } // DataPolicyManifestsClientListResponse contains the response from method DataPolicyManifestsClient.List. type DataPolicyManifestsClientListResponse struct { - DataPolicyManifestsClientListResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DataPolicyManifestsClientListResult contains the result from method DataPolicyManifestsClient.List. -type DataPolicyManifestsClientListResult struct { DataPolicyManifestListResult } // DefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionsClient.CreateOrUpdateAtManagementGroup. type DefinitionsClientCreateOrUpdateAtManagementGroupResponse struct { - DefinitionsClientCreateOrUpdateAtManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientCreateOrUpdateAtManagementGroupResult contains the result from method DefinitionsClient.CreateOrUpdateAtManagementGroup. -type DefinitionsClientCreateOrUpdateAtManagementGroupResult struct { Definition } // DefinitionsClientCreateOrUpdateResponse contains the response from method DefinitionsClient.CreateOrUpdate. type DefinitionsClientCreateOrUpdateResponse struct { - DefinitionsClientCreateOrUpdateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientCreateOrUpdateResult contains the result from method DefinitionsClient.CreateOrUpdate. -type DefinitionsClientCreateOrUpdateResult struct { Definition } // DefinitionsClientDeleteAtManagementGroupResponse contains the response from method DefinitionsClient.DeleteAtManagementGroup. type DefinitionsClientDeleteAtManagementGroupResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // placeholder for future response values } // DefinitionsClientDeleteResponse contains the response from method DefinitionsClient.Delete. type DefinitionsClientDeleteResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // placeholder for future response values } // DefinitionsClientGetAtManagementGroupResponse contains the response from method DefinitionsClient.GetAtManagementGroup. type DefinitionsClientGetAtManagementGroupResponse struct { - DefinitionsClientGetAtManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientGetAtManagementGroupResult contains the result from method DefinitionsClient.GetAtManagementGroup. -type DefinitionsClientGetAtManagementGroupResult struct { Definition } // DefinitionsClientGetBuiltInResponse contains the response from method DefinitionsClient.GetBuiltIn. type DefinitionsClientGetBuiltInResponse struct { - DefinitionsClientGetBuiltInResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientGetBuiltInResult contains the result from method DefinitionsClient.GetBuiltIn. -type DefinitionsClientGetBuiltInResult struct { Definition } // DefinitionsClientGetResponse contains the response from method DefinitionsClient.Get. type DefinitionsClientGetResponse struct { - DefinitionsClientGetResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientGetResult contains the result from method DefinitionsClient.Get. -type DefinitionsClientGetResult struct { Definition } // DefinitionsClientListBuiltInResponse contains the response from method DefinitionsClient.ListBuiltIn. type DefinitionsClientListBuiltInResponse struct { - DefinitionsClientListBuiltInResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientListBuiltInResult contains the result from method DefinitionsClient.ListBuiltIn. -type DefinitionsClientListBuiltInResult struct { DefinitionListResult } // DefinitionsClientListByManagementGroupResponse contains the response from method DefinitionsClient.ListByManagementGroup. type DefinitionsClientListByManagementGroupResponse struct { - DefinitionsClientListByManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientListByManagementGroupResult contains the result from method DefinitionsClient.ListByManagementGroup. -type DefinitionsClientListByManagementGroupResult struct { DefinitionListResult } // DefinitionsClientListResponse contains the response from method DefinitionsClient.List. type DefinitionsClientListResponse struct { - DefinitionsClientListResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// DefinitionsClientListResult contains the result from method DefinitionsClient.List. -type DefinitionsClientListResult struct { DefinitionListResult } // ExemptionsClientCreateOrUpdateResponse contains the response from method ExemptionsClient.CreateOrUpdate. type ExemptionsClientCreateOrUpdateResponse struct { - ExemptionsClientCreateOrUpdateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ExemptionsClientCreateOrUpdateResult contains the result from method ExemptionsClient.CreateOrUpdate. -type ExemptionsClientCreateOrUpdateResult struct { Exemption } // ExemptionsClientDeleteResponse contains the response from method ExemptionsClient.Delete. type ExemptionsClientDeleteResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // placeholder for future response values } // ExemptionsClientGetResponse contains the response from method ExemptionsClient.Get. type ExemptionsClientGetResponse struct { - ExemptionsClientGetResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ExemptionsClientGetResult contains the result from method ExemptionsClient.Get. -type ExemptionsClientGetResult struct { Exemption } // ExemptionsClientListForManagementGroupResponse contains the response from method ExemptionsClient.ListForManagementGroup. type ExemptionsClientListForManagementGroupResponse struct { - ExemptionsClientListForManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ExemptionsClientListForManagementGroupResult contains the result from method ExemptionsClient.ListForManagementGroup. -type ExemptionsClientListForManagementGroupResult struct { ExemptionListResult } // ExemptionsClientListForResourceGroupResponse contains the response from method ExemptionsClient.ListForResourceGroup. type ExemptionsClientListForResourceGroupResponse struct { - ExemptionsClientListForResourceGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ExemptionsClientListForResourceGroupResult contains the result from method ExemptionsClient.ListForResourceGroup. -type ExemptionsClientListForResourceGroupResult struct { ExemptionListResult } // ExemptionsClientListForResourceResponse contains the response from method ExemptionsClient.ListForResource. type ExemptionsClientListForResourceResponse struct { - ExemptionsClientListForResourceResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ExemptionsClientListForResourceResult contains the result from method ExemptionsClient.ListForResource. -type ExemptionsClientListForResourceResult struct { ExemptionListResult } // ExemptionsClientListResponse contains the response from method ExemptionsClient.List. type ExemptionsClientListResponse struct { - ExemptionsClientListResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ExemptionsClientListResult contains the result from method ExemptionsClient.List. -type ExemptionsClientListResult struct { ExemptionListResult } // SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionsClient.CreateOrUpdateAtManagementGroup. type SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse struct { - SetDefinitionsClientCreateOrUpdateAtManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientCreateOrUpdateAtManagementGroupResult contains the result from method SetDefinitionsClient.CreateOrUpdateAtManagementGroup. -type SetDefinitionsClientCreateOrUpdateAtManagementGroupResult struct { SetDefinition } // SetDefinitionsClientCreateOrUpdateResponse contains the response from method SetDefinitionsClient.CreateOrUpdate. type SetDefinitionsClientCreateOrUpdateResponse struct { - SetDefinitionsClientCreateOrUpdateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientCreateOrUpdateResult contains the result from method SetDefinitionsClient.CreateOrUpdate. -type SetDefinitionsClientCreateOrUpdateResult struct { SetDefinition } // SetDefinitionsClientDeleteAtManagementGroupResponse contains the response from method SetDefinitionsClient.DeleteAtManagementGroup. type SetDefinitionsClientDeleteAtManagementGroupResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // placeholder for future response values } // SetDefinitionsClientDeleteResponse contains the response from method SetDefinitionsClient.Delete. type SetDefinitionsClientDeleteResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // placeholder for future response values } // SetDefinitionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionsClient.GetAtManagementGroup. type SetDefinitionsClientGetAtManagementGroupResponse struct { - SetDefinitionsClientGetAtManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientGetAtManagementGroupResult contains the result from method SetDefinitionsClient.GetAtManagementGroup. -type SetDefinitionsClientGetAtManagementGroupResult struct { SetDefinition } // SetDefinitionsClientGetBuiltInResponse contains the response from method SetDefinitionsClient.GetBuiltIn. type SetDefinitionsClientGetBuiltInResponse struct { - SetDefinitionsClientGetBuiltInResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientGetBuiltInResult contains the result from method SetDefinitionsClient.GetBuiltIn. -type SetDefinitionsClientGetBuiltInResult struct { SetDefinition } // SetDefinitionsClientGetResponse contains the response from method SetDefinitionsClient.Get. type SetDefinitionsClientGetResponse struct { - SetDefinitionsClientGetResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientGetResult contains the result from method SetDefinitionsClient.Get. -type SetDefinitionsClientGetResult struct { SetDefinition } // SetDefinitionsClientListBuiltInResponse contains the response from method SetDefinitionsClient.ListBuiltIn. type SetDefinitionsClientListBuiltInResponse struct { - SetDefinitionsClientListBuiltInResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientListBuiltInResult contains the result from method SetDefinitionsClient.ListBuiltIn. -type SetDefinitionsClientListBuiltInResult struct { SetDefinitionListResult } // SetDefinitionsClientListByManagementGroupResponse contains the response from method SetDefinitionsClient.ListByManagementGroup. type SetDefinitionsClientListByManagementGroupResponse struct { - SetDefinitionsClientListByManagementGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientListByManagementGroupResult contains the result from method SetDefinitionsClient.ListByManagementGroup. -type SetDefinitionsClientListByManagementGroupResult struct { SetDefinitionListResult } // SetDefinitionsClientListResponse contains the response from method SetDefinitionsClient.List. type SetDefinitionsClientListResponse struct { - SetDefinitionsClientListResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// SetDefinitionsClientListResult contains the result from method SetDefinitionsClient.List. -type SetDefinitionsClientListResult struct { SetDefinitionListResult } diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go index 146e731c9cf1..336002827ab4 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_setdefinitions_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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. @@ -14,6 +14,7 @@ import ( "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" @@ -34,20 +35,24 @@ type SetDefinitionsClient struct { // 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 NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *SetDefinitionsClient { +func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionsClient, error) { if options == nil { options = &arm.ClientOptions{} } - ep := options.Endpoint - if len(ep) == 0 { - ep = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.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 := &SetDefinitionsClient{ subscriptionID: subscriptionID, - host: string(ep), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + host: ep, + pl: pl, } - return client + return client, nil } // CreateOrUpdate - This operation creates or updates a policy set definition in the given subscription with the given name. @@ -95,7 +100,7 @@ func (client *SetDefinitionsClient) createOrUpdateCreateRequest(ctx context.Cont // createOrUpdateHandleResponse handles the CreateOrUpdate response. func (client *SetDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (SetDefinitionsClientCreateOrUpdateResponse, error) { - result := SetDefinitionsClientCreateOrUpdateResponse{RawResponse: resp} + result := SetDefinitionsClientCreateOrUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinition); err != nil { return SetDefinitionsClientCreateOrUpdateResponse{}, err } @@ -149,7 +154,7 @@ func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest // createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { - result := SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{RawResponse: resp} + result := SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinition); err != nil { return SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } @@ -172,7 +177,7 @@ func (client *SetDefinitionsClient) Delete(ctx context.Context, policySetDefinit if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { return SetDefinitionsClientDeleteResponse{}, runtime.NewResponseError(resp) } - return SetDefinitionsClientDeleteResponse{RawResponse: resp}, nil + return SetDefinitionsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. @@ -216,7 +221,7 @@ func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { return SetDefinitionsClientDeleteAtManagementGroupResponse{}, runtime.NewResponseError(resp) } - return SetDefinitionsClientDeleteAtManagementGroupResponse{RawResponse: resp}, nil + return SetDefinitionsClientDeleteAtManagementGroupResponse{}, nil } // deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. @@ -284,7 +289,7 @@ func (client *SetDefinitionsClient) getCreateRequest(ctx context.Context, policy // getHandleResponse handles the Get response. func (client *SetDefinitionsClient) getHandleResponse(resp *http.Response) (SetDefinitionsClientGetResponse, error) { - result := SetDefinitionsClientGetResponse{RawResponse: resp} + result := SetDefinitionsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinition); err != nil { return SetDefinitionsClientGetResponse{}, err } @@ -337,7 +342,7 @@ func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx contex // getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. func (client *SetDefinitionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionsClientGetAtManagementGroupResponse, error) { - result := SetDefinitionsClientGetAtManagementGroupResponse{RawResponse: resp} + result := SetDefinitionsClientGetAtManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinition); err != nil { return SetDefinitionsClientGetAtManagementGroupResponse{}, err } @@ -384,7 +389,7 @@ func (client *SetDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, // getBuiltInHandleResponse handles the GetBuiltIn response. func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response) (SetDefinitionsClientGetBuiltInResponse, error) { - result := SetDefinitionsClientGetBuiltInResponse{RawResponse: resp} + result := SetDefinitionsClientGetBuiltInResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinition); err != nil { return SetDefinitionsClientGetBuiltInResponse{}, err } @@ -403,16 +408,32 @@ func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response // match the {value}. // If the operation fails it returns an *azcore.ResponseError type. // options - SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.List method. -func (client *SetDefinitionsClient) List(options *SetDefinitionsClientListOptions) *SetDefinitionsClientListPager { - return &SetDefinitionsClientListPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) +func (client *SetDefinitionsClient) List(options *SetDefinitionsClientListOptions) *runtime.Pager[SetDefinitionsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[SetDefinitionsClientListResponse]{ + More: func(page SetDefinitionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp SetDefinitionsClientListResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.SetDefinitionListResult.NextLink) + Fetcher: func(ctx context.Context, page *SetDefinitionsClientListResponse) (SetDefinitionsClientListResponse, 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 SetDefinitionsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SetDefinitionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SetDefinitionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) }, - } + }) } // listCreateRequest creates the List request. @@ -443,7 +464,7 @@ func (client *SetDefinitionsClient) listCreateRequest(ctx context.Context, optio // listHandleResponse handles the List response. func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (SetDefinitionsClientListResponse, error) { - result := SetDefinitionsClientListResponse{RawResponse: resp} + result := SetDefinitionsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionListResult); err != nil { return SetDefinitionsClientListResponse{}, err } @@ -456,16 +477,32 @@ func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (Set // If the operation fails it returns an *azcore.ResponseError type. // options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.ListBuiltIn // method. -func (client *SetDefinitionsClient) ListBuiltIn(options *SetDefinitionsClientListBuiltInOptions) *SetDefinitionsClientListBuiltInPager { - return &SetDefinitionsClientListBuiltInPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listBuiltInCreateRequest(ctx, options) +func (client *SetDefinitionsClient) ListBuiltIn(options *SetDefinitionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionsClientListBuiltInResponse] { + return runtime.NewPager(runtime.PageProcessor[SetDefinitionsClientListBuiltInResponse]{ + More: func(page SetDefinitionsClientListBuiltInResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp SetDefinitionsClientListBuiltInResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.SetDefinitionListResult.NextLink) + Fetcher: func(ctx context.Context, page *SetDefinitionsClientListBuiltInResponse) (SetDefinitionsClientListBuiltInResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBuiltInCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SetDefinitionsClientListBuiltInResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SetDefinitionsClientListBuiltInResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SetDefinitionsClientListBuiltInResponse{}, runtime.NewResponseError(resp) + } + return client.listBuiltInHandleResponse(resp) }, - } + }) } // listBuiltInCreateRequest creates the ListBuiltIn request. @@ -492,7 +529,7 @@ func (client *SetDefinitionsClient) listBuiltInCreateRequest(ctx context.Context // listBuiltInHandleResponse handles the ListBuiltIn response. func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Response) (SetDefinitionsClientListBuiltInResponse, error) { - result := SetDefinitionsClientListBuiltInResponse{RawResponse: resp} + result := SetDefinitionsClientListBuiltInResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionListResult); err != nil { return SetDefinitionsClientListBuiltInResponse{}, err } @@ -513,16 +550,32 @@ func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Respons // managementGroupID - The ID of the management group. // options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.ListByManagementGroup // method. -func (client *SetDefinitionsClient) ListByManagementGroup(managementGroupID string, options *SetDefinitionsClientListByManagementGroupOptions) *SetDefinitionsClientListByManagementGroupPager { - return &SetDefinitionsClientListByManagementGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listByManagementGroupCreateRequest(ctx, managementGroupID, options) +func (client *SetDefinitionsClient) ListByManagementGroup(managementGroupID string, options *SetDefinitionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionsClientListByManagementGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[SetDefinitionsClientListByManagementGroupResponse]{ + More: func(page SetDefinitionsClientListByManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp SetDefinitionsClientListByManagementGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.SetDefinitionListResult.NextLink) + Fetcher: func(ctx context.Context, page *SetDefinitionsClientListByManagementGroupResponse) (SetDefinitionsClientListByManagementGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByManagementGroupCreateRequest(ctx, managementGroupID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SetDefinitionsClientListByManagementGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SetDefinitionsClientListByManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SetDefinitionsClientListByManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByManagementGroupHandleResponse(resp) }, - } + }) } // listByManagementGroupCreateRequest creates the ListByManagementGroup request. @@ -553,7 +606,7 @@ func (client *SetDefinitionsClient) listByManagementGroupCreateRequest(ctx conte // listByManagementGroupHandleResponse handles the ListByManagementGroup response. func (client *SetDefinitionsClient) listByManagementGroupHandleResponse(resp *http.Response) (SetDefinitionsClientListByManagementGroupResponse, error) { - result := SetDefinitionsClientListByManagementGroupResponse{RawResponse: resp} + result := SetDefinitionsClientListByManagementGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionListResult); err != nil { return SetDefinitionsClientListByManagementGroupResponse{}, err } diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go index d94878a4a380..d846881aabad 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_time_rfc3339.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//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.