From 0a626ab49b919b10eefeeb76d0d53e3bf7d86eb5 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 25 Mar 2023 01:43:32 +0000 Subject: [PATCH] CodeGen from PR 23292 in Azure/azure-rest-api-specs Merge 04b319181219f52115618f3a5aaa7a58ed3e3a58 into 2ac8dec9cbc4ad4db7537de603339f069d482078 --- .../resources/armlocks/CHANGELOG.md | 9 + ...t.go => authorizationoperations_client.go} | 32 +- .../resources/armlocks/autorest.md | 6 +- .../resources/armlocks/client_factory.go | 49 ++ ...zz_generated_constants.go => constants.go} | 3 +- sdk/resourcemanager/resources/armlocks/go.mod | 20 +- sdk/resourcemanager/resources/armlocks/go.sum | 40 +- ...ks_client.go => managementlocks_client.go} | 282 ++++++------ .../{zz_generated_models.go => models.go} | 15 +- .../resources/armlocks/models_serde.go | 418 ++++++++++++++++++ ...ed_response_types.go => response_types.go} | 11 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...ple_authorizationoperations_client_test.go | 41 -- ...ted_example_managementlocks_client_test.go | 406 ----------------- .../armlocks/zz_generated_models_serde.go | 92 ---- 15 files changed, 668 insertions(+), 759 deletions(-) rename sdk/resourcemanager/resources/armlocks/{zz_generated_authorizationoperations_client.go => authorizationoperations_client.go} (78%) create mode 100644 sdk/resourcemanager/resources/armlocks/client_factory.go rename sdk/resourcemanager/resources/armlocks/{zz_generated_constants.go => constants.go} (97%) rename sdk/resourcemanager/resources/armlocks/{zz_generated_managementlocks_client.go => managementlocks_client.go} (85%) rename sdk/resourcemanager/resources/armlocks/{zz_generated_models.go => models.go} (95%) create mode 100644 sdk/resourcemanager/resources/armlocks/models_serde.go rename sdk/resourcemanager/resources/armlocks/{zz_generated_response_types.go => response_types.go} (91%) rename sdk/resourcemanager/resources/armlocks/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) delete mode 100644 sdk/resourcemanager/resources/armlocks/ze_generated_example_authorizationoperations_client_test.go delete mode 100644 sdk/resourcemanager/resources/armlocks/ze_generated_example_managementlocks_client_test.go delete mode 100644 sdk/resourcemanager/resources/armlocks/zz_generated_models_serde.go diff --git a/sdk/resourcemanager/resources/armlocks/CHANGELOG.md b/sdk/resourcemanager/resources/armlocks/CHANGELOG.md index 76e60b2c9550..e4e94824bd33 100644 --- a/sdk/resourcemanager/resources/armlocks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlocks/CHANGELOG.md @@ -1,5 +1,14 @@ # Release History +## 1.1.0 (2023-03-25) +### Features Added + +- New function `NewClientFactory(string, azcore.TokenCredential, *arm.ClientOptions) (*ClientFactory, error)` +- New function `*ClientFactory.NewAuthorizationOperationsClient() *AuthorizationOperationsClient` +- New function `*ClientFactory.NewManagementLocksClient() *ManagementLocksClient` +- New struct `ClientFactory` + + ## 1.0.0 (2022-05-16) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_authorizationoperations_client.go b/sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go similarity index 78% rename from sdk/resourcemanager/resources/armlocks/zz_generated_authorizationoperations_client.go rename to sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go index 9dcade147923..960aac853cd0 100644 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_authorizationoperations_client.go +++ b/sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlocks @@ -12,8 +13,6 @@ import ( "context" "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" @@ -22,37 +21,28 @@ import ( // AuthorizationOperationsClient contains the methods for the AuthorizationOperations group. // Don't use this type directly, use NewAuthorizationOperationsClient() instead. type AuthorizationOperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewAuthorizationOperationsClient creates a new instance of AuthorizationOperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAuthorizationOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationOperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AuthorizationOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AuthorizationOperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available Microsoft.Authorization REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// options - AuthorizationOperationsClientListOptions contains the optional parameters for the AuthorizationOperationsClient.List -// method. +// - options - AuthorizationOperationsClientListOptions contains the optional parameters for the AuthorizationOperationsClient.NewListPager +// method. func (client *AuthorizationOperationsClient) NewListPager(options *AuthorizationOperationsClientListOptions) *runtime.Pager[AuthorizationOperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AuthorizationOperationsClientListResponse]{ More: func(page AuthorizationOperationsClientListResponse) bool { @@ -69,7 +59,7 @@ func (client *AuthorizationOperationsClient) NewListPager(options *Authorization if err != nil { return AuthorizationOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AuthorizationOperationsClientListResponse{}, err } @@ -84,7 +74,7 @@ func (client *AuthorizationOperationsClient) NewListPager(options *Authorization // listCreateRequest creates the List request. func (client *AuthorizationOperationsClient) listCreateRequest(ctx context.Context, options *AuthorizationOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Authorization/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/resources/armlocks/autorest.md b/sdk/resourcemanager/resources/armlocks/autorest.md index 5712ce226195..6b8c35abad7c 100644 --- a/sdk/resourcemanager/resources/armlocks/autorest.md +++ b/sdk/resourcemanager/resources/armlocks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/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: 1.0.0 +module-version: 1.1.0 package-locks: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armlocks/client_factory.go b/sdk/resourcemanager/resources/armlocks/client_factory.go new file mode 100644 index 000000000000..1063ee97b20d --- /dev/null +++ b/sdk/resourcemanager/resources/armlocks/client_factory.go @@ -0,0 +1,49 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armlocks + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAuthorizationOperationsClient() *AuthorizationOperationsClient { + subClient, _ := NewAuthorizationOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewManagementLocksClient() *ManagementLocksClient { + subClient, _ := NewManagementLocksClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_constants.go b/sdk/resourcemanager/resources/armlocks/constants.go similarity index 97% rename from sdk/resourcemanager/resources/armlocks/zz_generated_constants.go rename to sdk/resourcemanager/resources/armlocks/constants.go index f913c19a69c8..99052d38b1a7 100644 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armlocks/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlocks const ( moduleName = "armlocks" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armlocks/go.mod b/sdk/resourcemanager/resources/armlocks/go.mod index 9d97bb19c067..c63a165f6b5c 100644 --- a/sdk/resourcemanager/resources/armlocks/go.mod +++ b/sdk/resourcemanager/resources/armlocks/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.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 - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/resources/armlocks/go.sum b/sdk/resourcemanager/resources/armlocks/go.sum index ed5b814680ee..f54c298864a1 100644 --- a/sdk/resourcemanager/resources/armlocks/go.sum +++ b/sdk/resourcemanager/resources/armlocks/go.sum @@ -1,33 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -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/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -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/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= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_managementlocks_client.go b/sdk/resourcemanager/resources/armlocks/managementlocks_client.go similarity index 85% rename from sdk/resourcemanager/resources/armlocks/zz_generated_managementlocks_client.go rename to sdk/resourcemanager/resources/armlocks/managementlocks_client.go index 05ea06660800..1c0547445fa5 100644 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_managementlocks_client.go +++ b/sdk/resourcemanager/resources/armlocks/managementlocks_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlocks @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,31 +24,22 @@ import ( // ManagementLocksClient contains the methods for the ManagementLocks group. // Don't use this type directly, use NewManagementLocksClient() instead. type ManagementLocksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewManagementLocksClient creates a new instance of ManagementLocksClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - 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 NewManagementLocksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementLocksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ManagementLocksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ManagementLocksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,19 +48,20 @@ func NewManagementLocksClient(subscriptionID string, credential azcore.TokenCred // To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* // actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group to lock. -// lockName - The lock name. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any -// control characters. -// parameters - The management lock parameters. -// options - ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group to lock. +// - lockName - The lock name. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any +// control characters. +// - parameters - The management lock parameters. +// - options - ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel +// method. func (client *ManagementLocksClient) CreateOrUpdateAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions) (ManagementLocksClientCreateOrUpdateAtResourceGroupLevelResponse, error) { req, err := client.createOrUpdateAtResourceGroupLevelCreateRequest(ctx, resourceGroupName, lockName, parameters, options) if err != nil { return ManagementLocksClientCreateOrUpdateAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientCreateOrUpdateAtResourceGroupLevelResponse{}, err } @@ -95,7 +86,7 @@ func (client *ManagementLocksClient) createOrUpdateAtResourceGroupLevelCreateReq return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,23 +110,24 @@ func (client *ManagementLocksClient) createOrUpdateAtResourceGroupLevelHandleRes // create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* // actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group containing the resource to lock. -// resourceProviderNamespace - The resource provider namespace of the resource to lock. -// parentResourcePath - The parent resource identity. -// resourceType - The resource type of the resource to lock. -// resourceName - The name of the resource to lock. -// lockName - The name of lock. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any -// control characters. -// parameters - Parameters for creating or updating a management lock. -// options - ManagementLocksClientCreateOrUpdateAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceLevel -// method. +// - resourceGroupName - The name of the resource group containing the resource to lock. +// - resourceProviderNamespace - The resource provider namespace of the resource to lock. +// - parentResourcePath - The parent resource identity. +// - resourceType - The resource type of the resource to lock. +// - resourceName - The name of the resource to lock. +// - lockName - The name of lock. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any +// control characters. +// - parameters - Parameters for creating or updating a management lock. +// - options - ManagementLocksClientCreateOrUpdateAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceLevel +// method. func (client *ManagementLocksClient) CreateOrUpdateAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtResourceLevelOptions) (ManagementLocksClientCreateOrUpdateAtResourceLevelResponse, error) { req, err := client.createOrUpdateAtResourceLevelCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, parameters, options) if err != nil { return ManagementLocksClientCreateOrUpdateAtResourceLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientCreateOrUpdateAtResourceLevelResponse{}, err } @@ -170,7 +162,7 @@ func (client *ManagementLocksClient) createOrUpdateAtResourceLevelCreateRequest( return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -194,18 +186,19 @@ func (client *ManagementLocksClient) createOrUpdateAtResourceLevelHandleResponse // To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* // actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// lockName - The name of lock. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any -// control characters. -// parameters - The management lock parameters. -// options - ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel -// method. +// - lockName - The name of lock. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any +// control characters. +// - parameters - The management lock parameters. +// - options - ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel +// method. func (client *ManagementLocksClient) CreateOrUpdateAtSubscriptionLevel(ctx context.Context, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions) (ManagementLocksClientCreateOrUpdateAtSubscriptionLevelResponse, error) { req, err := client.createOrUpdateAtSubscriptionLevelCreateRequest(ctx, lockName, parameters, options) if err != nil { return ManagementLocksClientCreateOrUpdateAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientCreateOrUpdateAtSubscriptionLevelResponse{}, err } @@ -226,7 +219,7 @@ func (client *ManagementLocksClient) createOrUpdateAtSubscriptionLevelCreateRequ return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -248,22 +241,23 @@ func (client *ManagementLocksClient) createOrUpdateAtSubscriptionLevelHandleResp // CreateOrUpdateByScope - Create or update a management lock by scope. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// scope - The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, -// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for -// resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' -// for -// resources. -// lockName - The name of lock. -// parameters - Create or update management lock parameters. -// options - ManagementLocksClientCreateOrUpdateByScopeOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateByScope -// method. +// - scope - The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, +// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for +// resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' +// for +// resources. +// - lockName - The name of lock. +// - parameters - Create or update management lock parameters. +// - options - ManagementLocksClientCreateOrUpdateByScopeOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateByScope +// method. func (client *ManagementLocksClient) CreateOrUpdateByScope(ctx context.Context, scope string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateByScopeOptions) (ManagementLocksClientCreateOrUpdateByScopeResponse, error) { req, err := client.createOrUpdateByScopeCreateRequest(ctx, scope, lockName, parameters, options) if err != nil { return ManagementLocksClientCreateOrUpdateByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientCreateOrUpdateByScopeResponse{}, err } @@ -284,7 +278,7 @@ func (client *ManagementLocksClient) createOrUpdateByScopeCreateRequest(ctx cont return nil, errors.New("parameter lockName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{lockName}", url.PathEscape(lockName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -308,17 +302,18 @@ func (client *ManagementLocksClient) createOrUpdateByScopeHandleResponse(resp *h // actions. Of the built-in roles, only Owner and User Access Administrator are granted // those actions. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group containing the lock. -// lockName - The name of lock to delete. -// options - ManagementLocksClientDeleteAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group containing the lock. +// - lockName - The name of lock to delete. +// - options - ManagementLocksClientDeleteAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceGroupLevel +// method. func (client *ManagementLocksClient) DeleteAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string, options *ManagementLocksClientDeleteAtResourceGroupLevelOptions) (ManagementLocksClientDeleteAtResourceGroupLevelResponse, error) { req, err := client.deleteAtResourceGroupLevelCreateRequest(ctx, resourceGroupName, lockName, options) if err != nil { return ManagementLocksClientDeleteAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientDeleteAtResourceGroupLevelResponse{}, err } @@ -343,7 +338,7 @@ func (client *ManagementLocksClient) deleteAtResourceGroupLevelCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -358,21 +353,22 @@ func (client *ManagementLocksClient) deleteAtResourceGroupLevelCreateRequest(ctx // actions. Of the built-in roles, only Owner and User Access Administrator are granted // those actions. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group containing the resource with the lock to delete. -// resourceProviderNamespace - The resource provider namespace of the resource with the lock to delete. -// parentResourcePath - The parent resource identity. -// resourceType - The resource type of the resource with the lock to delete. -// resourceName - The name of the resource with the lock to delete. -// lockName - The name of the lock to delete. -// options - ManagementLocksClientDeleteAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceLevel -// method. +// - resourceGroupName - The name of the resource group containing the resource with the lock to delete. +// - resourceProviderNamespace - The resource provider namespace of the resource with the lock to delete. +// - parentResourcePath - The parent resource identity. +// - resourceType - The resource type of the resource with the lock to delete. +// - resourceName - The name of the resource with the lock to delete. +// - lockName - The name of the lock to delete. +// - options - ManagementLocksClientDeleteAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceLevel +// method. func (client *ManagementLocksClient) DeleteAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, options *ManagementLocksClientDeleteAtResourceLevelOptions) (ManagementLocksClientDeleteAtResourceLevelResponse, error) { req, err := client.deleteAtResourceLevelCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, options) if err != nil { return ManagementLocksClientDeleteAtResourceLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientDeleteAtResourceLevelResponse{}, err } @@ -407,7 +403,7 @@ func (client *ManagementLocksClient) deleteAtResourceLevelCreateRequest(ctx cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -422,16 +418,17 @@ func (client *ManagementLocksClient) deleteAtResourceLevelCreateRequest(ctx cont // actions. Of the built-in roles, only Owner and User Access Administrator are granted // those actions. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// lockName - The name of lock to delete. -// options - ManagementLocksClientDeleteAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtSubscriptionLevel -// method. +// - lockName - The name of lock to delete. +// - options - ManagementLocksClientDeleteAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtSubscriptionLevel +// method. func (client *ManagementLocksClient) DeleteAtSubscriptionLevel(ctx context.Context, lockName string, options *ManagementLocksClientDeleteAtSubscriptionLevelOptions) (ManagementLocksClientDeleteAtSubscriptionLevelResponse, error) { req, err := client.deleteAtSubscriptionLevelCreateRequest(ctx, lockName, options) if err != nil { return ManagementLocksClientDeleteAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientDeleteAtSubscriptionLevelResponse{}, err } @@ -452,7 +449,7 @@ func (client *ManagementLocksClient) deleteAtSubscriptionLevelCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -465,17 +462,18 @@ func (client *ManagementLocksClient) deleteAtSubscriptionLevelCreateRequest(ctx // DeleteByScope - Delete a management lock by scope. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// scope - The scope for the lock. -// lockName - The name of lock. -// options - ManagementLocksClientDeleteByScopeOptions contains the optional parameters for the ManagementLocksClient.DeleteByScope -// method. +// - scope - The scope for the lock. +// - lockName - The name of lock. +// - options - ManagementLocksClientDeleteByScopeOptions contains the optional parameters for the ManagementLocksClient.DeleteByScope +// method. func (client *ManagementLocksClient) DeleteByScope(ctx context.Context, scope string, lockName string, options *ManagementLocksClientDeleteByScopeOptions) (ManagementLocksClientDeleteByScopeResponse, error) { req, err := client.deleteByScopeCreateRequest(ctx, scope, lockName, options) if err != nil { return ManagementLocksClientDeleteByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientDeleteByScopeResponse{}, err } @@ -496,7 +494,7 @@ func (client *ManagementLocksClient) deleteByScopeCreateRequest(ctx context.Cont return nil, errors.New("parameter lockName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{lockName}", url.PathEscape(lockName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -509,17 +507,18 @@ func (client *ManagementLocksClient) deleteByScopeCreateRequest(ctx context.Cont // GetAtResourceGroupLevel - Gets a management lock at the resource group level. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the locked resource group. -// lockName - The name of the lock to get. -// options - ManagementLocksClientGetAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the locked resource group. +// - lockName - The name of the lock to get. +// - options - ManagementLocksClientGetAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceGroupLevel +// method. func (client *ManagementLocksClient) GetAtResourceGroupLevel(ctx context.Context, resourceGroupName string, lockName string, options *ManagementLocksClientGetAtResourceGroupLevelOptions) (ManagementLocksClientGetAtResourceGroupLevelResponse, error) { req, err := client.getAtResourceGroupLevelCreateRequest(ctx, resourceGroupName, lockName, options) if err != nil { return ManagementLocksClientGetAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientGetAtResourceGroupLevelResponse{}, err } @@ -544,7 +543,7 @@ func (client *ManagementLocksClient) getAtResourceGroupLevelCreateRequest(ctx co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -566,21 +565,22 @@ func (client *ManagementLocksClient) getAtResourceGroupLevelHandleResponse(resp // GetAtResourceLevel - Get the management lock of a resource or any level below resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group. -// resourceProviderNamespace - The namespace of the resource provider. -// parentResourcePath - An extra path parameter needed in some services, like SQL Databases. -// resourceType - The type of the resource. -// resourceName - The name of the resource. -// lockName - The name of lock. -// options - ManagementLocksClientGetAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceLevel -// method. +// - resourceGroupName - The name of the resource group. +// - resourceProviderNamespace - The namespace of the resource provider. +// - parentResourcePath - An extra path parameter needed in some services, like SQL Databases. +// - resourceType - The type of the resource. +// - resourceName - The name of the resource. +// - lockName - The name of lock. +// - options - ManagementLocksClientGetAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceLevel +// method. func (client *ManagementLocksClient) GetAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, options *ManagementLocksClientGetAtResourceLevelOptions) (ManagementLocksClientGetAtResourceLevelResponse, error) { req, err := client.getAtResourceLevelCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, options) if err != nil { return ManagementLocksClientGetAtResourceLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientGetAtResourceLevelResponse{}, err } @@ -615,7 +615,7 @@ func (client *ManagementLocksClient) getAtResourceLevelCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -637,16 +637,17 @@ func (client *ManagementLocksClient) getAtResourceLevelHandleResponse(resp *http // GetAtSubscriptionLevel - Gets a management lock at the subscription level. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// lockName - The name of the lock to get. -// options - ManagementLocksClientGetAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtSubscriptionLevel -// method. +// - lockName - The name of the lock to get. +// - options - ManagementLocksClientGetAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtSubscriptionLevel +// method. func (client *ManagementLocksClient) GetAtSubscriptionLevel(ctx context.Context, lockName string, options *ManagementLocksClientGetAtSubscriptionLevelOptions) (ManagementLocksClientGetAtSubscriptionLevelResponse, error) { req, err := client.getAtSubscriptionLevelCreateRequest(ctx, lockName, options) if err != nil { return ManagementLocksClientGetAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientGetAtSubscriptionLevelResponse{}, err } @@ -667,7 +668,7 @@ func (client *ManagementLocksClient) getAtSubscriptionLevelCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -689,17 +690,18 @@ func (client *ManagementLocksClient) getAtSubscriptionLevelHandleResponse(resp * // GetByScope - Get a management lock by scope. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// scope - The scope for the lock. -// lockName - The name of lock. -// options - ManagementLocksClientGetByScopeOptions contains the optional parameters for the ManagementLocksClient.GetByScope -// method. +// - scope - The scope for the lock. +// - lockName - The name of lock. +// - options - ManagementLocksClientGetByScopeOptions contains the optional parameters for the ManagementLocksClient.GetByScope +// method. func (client *ManagementLocksClient) GetByScope(ctx context.Context, scope string, lockName string, options *ManagementLocksClientGetByScopeOptions) (ManagementLocksClientGetByScopeResponse, error) { req, err := client.getByScopeCreateRequest(ctx, scope, lockName, options) if err != nil { return ManagementLocksClientGetByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientGetByScopeResponse{}, err } @@ -720,7 +722,7 @@ func (client *ManagementLocksClient) getByScopeCreateRequest(ctx context.Context return nil, errors.New("parameter lockName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{lockName}", url.PathEscape(lockName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -741,11 +743,11 @@ func (client *ManagementLocksClient) getByScopeHandleResponse(resp *http.Respons } // NewListAtResourceGroupLevelPager - Gets all the management locks for a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group containing the locks to get. -// options - ManagementLocksClientListAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.ListAtResourceGroupLevel -// method. +// - resourceGroupName - The name of the resource group containing the locks to get. +// - options - ManagementLocksClientListAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceGroupLevelPager +// method. func (client *ManagementLocksClient) NewListAtResourceGroupLevelPager(resourceGroupName string, options *ManagementLocksClientListAtResourceGroupLevelOptions) *runtime.Pager[ManagementLocksClientListAtResourceGroupLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementLocksClientListAtResourceGroupLevelResponse]{ More: func(page ManagementLocksClientListAtResourceGroupLevelResponse) bool { @@ -762,7 +764,7 @@ func (client *ManagementLocksClient) NewListAtResourceGroupLevelPager(resourceGr if err != nil { return ManagementLocksClientListAtResourceGroupLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientListAtResourceGroupLevelResponse{}, err } @@ -785,7 +787,7 @@ func (client *ManagementLocksClient) listAtResourceGroupLevelCreateRequest(ctx c return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -809,15 +811,15 @@ func (client *ManagementLocksClient) listAtResourceGroupLevelHandleResponse(resp } // NewListAtResourceLevelPager - Gets all the management locks for a resource or any level below resource. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - The name of the resource group containing the locked resource. The name is case insensitive. -// resourceProviderNamespace - The namespace of the resource provider. -// parentResourcePath - The parent resource identity. -// resourceType - The resource type of the locked resource. -// resourceName - The name of the locked resource. -// options - ManagementLocksClientListAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.ListAtResourceLevel -// method. +// - resourceGroupName - The name of the resource group containing the locked resource. The name is case insensitive. +// - resourceProviderNamespace - The namespace of the resource provider. +// - parentResourcePath - The parent resource identity. +// - resourceType - The resource type of the locked resource. +// - resourceName - The name of the locked resource. +// - options - ManagementLocksClientListAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceLevelPager +// method. func (client *ManagementLocksClient) NewListAtResourceLevelPager(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ManagementLocksClientListAtResourceLevelOptions) *runtime.Pager[ManagementLocksClientListAtResourceLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementLocksClientListAtResourceLevelResponse]{ More: func(page ManagementLocksClientListAtResourceLevelResponse) bool { @@ -834,7 +836,7 @@ func (client *ManagementLocksClient) NewListAtResourceLevelPager(resourceGroupNa if err != nil { return ManagementLocksClientListAtResourceLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientListAtResourceLevelResponse{}, err } @@ -867,7 +869,7 @@ func (client *ManagementLocksClient) listAtResourceLevelCreateRequest(ctx contex return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -891,10 +893,10 @@ func (client *ManagementLocksClient) listAtResourceLevelHandleResponse(resp *htt } // NewListAtSubscriptionLevelPager - Gets all the management locks for a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// options - ManagementLocksClientListAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.ListAtSubscriptionLevel -// method. +// - options - ManagementLocksClientListAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtSubscriptionLevelPager +// method. func (client *ManagementLocksClient) NewListAtSubscriptionLevelPager(options *ManagementLocksClientListAtSubscriptionLevelOptions) *runtime.Pager[ManagementLocksClientListAtSubscriptionLevelResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementLocksClientListAtSubscriptionLevelResponse]{ More: func(page ManagementLocksClientListAtSubscriptionLevelResponse) bool { @@ -911,7 +913,7 @@ func (client *ManagementLocksClient) NewListAtSubscriptionLevelPager(options *Ma if err != nil { return ManagementLocksClientListAtSubscriptionLevelResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientListAtSubscriptionLevelResponse{}, err } @@ -930,7 +932,7 @@ func (client *ManagementLocksClient) listAtSubscriptionLevelCreateRequest(ctx co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -954,15 +956,15 @@ func (client *ManagementLocksClient) listAtSubscriptionLevelHandleResponse(resp } // NewListByScopePager - Gets all the management locks for a scope. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// scope - The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, -// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for -// resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' -// for -// resources. -// options - ManagementLocksClientListByScopeOptions contains the optional parameters for the ManagementLocksClient.ListByScope -// method. +// - scope - The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, +// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for +// resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' +// for +// resources. +// - options - ManagementLocksClientListByScopeOptions contains the optional parameters for the ManagementLocksClient.NewListByScopePager +// method. func (client *ManagementLocksClient) NewListByScopePager(scope string, options *ManagementLocksClientListByScopeOptions) *runtime.Pager[ManagementLocksClientListByScopeResponse] { return runtime.NewPager(runtime.PagingHandler[ManagementLocksClientListByScopeResponse]{ More: func(page ManagementLocksClientListByScopeResponse) bool { @@ -979,7 +981,7 @@ func (client *ManagementLocksClient) NewListByScopePager(scope string, options * if err != nil { return ManagementLocksClientListByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementLocksClientListByScopeResponse{}, err } @@ -998,7 +1000,7 @@ func (client *ManagementLocksClient) listByScopeCreateRequest(ctx context.Contex return nil, errors.New("parameter scope cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_models.go b/sdk/resourcemanager/resources/armlocks/models.go similarity index 95% rename from sdk/resourcemanager/resources/armlocks/zz_generated_models.go rename to sdk/resourcemanager/resources/armlocks/models.go index 32bbdbdefa1b..0333f4b643ad 100644 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_models.go +++ b/sdk/resourcemanager/resources/armlocks/models.go @@ -5,12 +5,14 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlocks import "time" -// AuthorizationOperationsClientListOptions contains the optional parameters for the AuthorizationOperationsClient.List method. +// AuthorizationOperationsClientListOptions contains the optional parameters for the AuthorizationOperationsClient.NewListPager +// method. type AuthorizationOperationsClientListOptions struct { // placeholder for future optional parameters } @@ -18,7 +20,7 @@ type AuthorizationOperationsClientListOptions struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -167,28 +169,29 @@ type ManagementLocksClientGetByScopeOptions struct { // placeholder for future optional parameters } -// ManagementLocksClientListAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.ListAtResourceGroupLevel +// ManagementLocksClientListAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceGroupLevelPager // method. type ManagementLocksClientListAtResourceGroupLevelOptions struct { // The filter to apply on the operation. Filter *string } -// ManagementLocksClientListAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.ListAtResourceLevel +// ManagementLocksClientListAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceLevelPager // method. type ManagementLocksClientListAtResourceLevelOptions struct { // The filter to apply on the operation. Filter *string } -// ManagementLocksClientListAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.ListAtSubscriptionLevel +// ManagementLocksClientListAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtSubscriptionLevelPager // method. type ManagementLocksClientListAtSubscriptionLevelOptions struct { // The filter to apply on the operation. Filter *string } -// ManagementLocksClientListByScopeOptions contains the optional parameters for the ManagementLocksClient.ListByScope method. +// ManagementLocksClientListByScopeOptions contains the optional parameters for the ManagementLocksClient.NewListByScopePager +// method. type ManagementLocksClientListByScopeOptions struct { // The filter to apply on the operation. Filter *string diff --git a/sdk/resourcemanager/resources/armlocks/models_serde.go b/sdk/resourcemanager/resources/armlocks/models_serde.go new file mode 100644 index 000000000000..a335e2d8184d --- /dev/null +++ b/sdk/resourcemanager/resources/armlocks/models_serde.go @@ -0,0 +1,418 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armlocks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementLockListResult. +func (m ManagementLockListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockListResult. +func (m *ManagementLockListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementLockObject. +func (m ManagementLockObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "systemData", m.SystemData) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockObject. +func (m *ManagementLockObject) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &m.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementLockOwner. +func (m ManagementLockOwner) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applicationId", m.ApplicationID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockOwner. +func (m *ManagementLockOwner) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "applicationId": + err = unpopulate(val, "ApplicationID", &m.ApplicationID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementLockProperties. +func (m ManagementLockProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "level", m.Level) + populate(objectMap, "notes", m.Notes) + populate(objectMap, "owners", m.Owners) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockProperties. +func (m *ManagementLockProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "level": + err = unpopulate(val, "Level", &m.Level) + delete(rawMsg, key) + case "notes": + err = unpopulate(val, "Notes", &m.Notes) + delete(rawMsg, key) + case "owners": + err = unpopulate(val, "Owners", &m.Owners) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_response_types.go b/sdk/resourcemanager/resources/armlocks/response_types.go similarity index 91% rename from sdk/resourcemanager/resources/armlocks/zz_generated_response_types.go rename to sdk/resourcemanager/resources/armlocks/response_types.go index 2c89bef6ae77..91d42f455b70 100644 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_response_types.go +++ b/sdk/resourcemanager/resources/armlocks/response_types.go @@ -5,10 +5,11 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlocks -// AuthorizationOperationsClientListResponse contains the response from method AuthorizationOperationsClient.List. +// AuthorizationOperationsClientListResponse contains the response from method AuthorizationOperationsClient.NewListPager. type AuthorizationOperationsClientListResponse struct { OperationListResult } @@ -73,22 +74,22 @@ type ManagementLocksClientGetByScopeResponse struct { ManagementLockObject } -// ManagementLocksClientListAtResourceGroupLevelResponse contains the response from method ManagementLocksClient.ListAtResourceGroupLevel. +// ManagementLocksClientListAtResourceGroupLevelResponse contains the response from method ManagementLocksClient.NewListAtResourceGroupLevelPager. type ManagementLocksClientListAtResourceGroupLevelResponse struct { ManagementLockListResult } -// ManagementLocksClientListAtResourceLevelResponse contains the response from method ManagementLocksClient.ListAtResourceLevel. +// ManagementLocksClientListAtResourceLevelResponse contains the response from method ManagementLocksClient.NewListAtResourceLevelPager. type ManagementLocksClientListAtResourceLevelResponse struct { ManagementLockListResult } -// ManagementLocksClientListAtSubscriptionLevelResponse contains the response from method ManagementLocksClient.ListAtSubscriptionLevel. +// ManagementLocksClientListAtSubscriptionLevelResponse contains the response from method ManagementLocksClient.NewListAtSubscriptionLevelPager. type ManagementLocksClientListAtSubscriptionLevelResponse struct { ManagementLockListResult } -// ManagementLocksClientListByScopeResponse contains the response from method ManagementLocksClient.ListByScope. +// ManagementLocksClientListByScopeResponse contains the response from method ManagementLocksClient.NewListByScopePager. type ManagementLocksClientListByScopeResponse struct { ManagementLockListResult } diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_time_rfc3339.go b/sdk/resourcemanager/resources/armlocks/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/resources/armlocks/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/resources/armlocks/time_rfc3339.go index 4a26732c6b54..631fbd0292d6 100644 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/resources/armlocks/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlocks @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/resources/armlocks/ze_generated_example_authorizationoperations_client_test.go b/sdk/resourcemanager/resources/armlocks/ze_generated_example_authorizationoperations_client_test.go deleted file mode 100644 index 65c8038c9e32..000000000000 --- a/sdk/resourcemanager/resources/armlocks/ze_generated_example_authorizationoperations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armlocks_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json -func ExampleAuthorizationOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewAuthorizationOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armlocks/ze_generated_example_managementlocks_client_test.go b/sdk/resourcemanager/resources/armlocks/ze_generated_example_managementlocks_client_test.go deleted file mode 100644 index 06d8c99bd1b0..000000000000 --- a/sdk/resourcemanager/resources/armlocks/ze_generated_example_managementlocks_client_test.go +++ /dev/null @@ -1,406 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armlocks_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/armlocks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdateAtResourceGroupLevel(ctx, - "resourcegroupname", - "testlock", - armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json -func ExampleManagementLocksClient_DeleteAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteAtResourceGroupLevel(ctx, - "resourcegroupname", - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json -func ExampleManagementLocksClient_GetAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAtResourceGroupLevel(ctx, - "resourcegroupname", - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json -func ExampleManagementLocksClient_CreateOrUpdateByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdateByScope(ctx, - "subscriptions/subscriptionId", - "testlock", - armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json -func ExampleManagementLocksClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteByScope(ctx, - "subscriptions/subscriptionId", - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json -func ExampleManagementLocksClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByScope(ctx, - "subscriptions/subscriptionId", - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdateAtResourceLevel(ctx, - "resourcegroupname", - "Microsoft.Storage", - "parentResourcePath", - "storageAccounts", - "teststorageaccount", - "testlock", - armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json -func ExampleManagementLocksClient_DeleteAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteAtResourceLevel(ctx, - "resourcegroupname", - "Microsoft.Storage", - "parentResourcePath", - "storageAccounts", - "teststorageaccount", - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json -func ExampleManagementLocksClient_GetAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAtResourceLevel(ctx, - "resourcegroupname", - "Microsoft.Storage", - "parentResourcePath", - "storageAccounts", - "teststorageaccount", - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdateAtSubscriptionLevel(ctx, - "testlock", - armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json -func ExampleManagementLocksClient_DeleteAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteAtSubscriptionLevel(ctx, - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json -func ExampleManagementLocksClient_GetAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAtSubscriptionLevel(ctx, - "testlock", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json -func ExampleManagementLocksClient_NewListAtResourceGroupLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAtResourceGroupLevelPager("resourcegroupname", - &armlocks.ManagementLocksClientListAtResourceGroupLevelOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json -func ExampleManagementLocksClient_NewListAtResourceLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAtResourceLevelPager("resourcegroupname", - "Microsoft.Storage", - "parentResourcePath", - "storageAccounts", - "teststorageaccount", - &armlocks.ManagementLocksClientListAtResourceLevelOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json -func ExampleManagementLocksClient_NewListAtSubscriptionLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAtSubscriptionLevelPager(&armlocks.ManagementLocksClientListAtSubscriptionLevelOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json -func ExampleManagementLocksClient_NewListByScopePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armlocks.NewManagementLocksClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByScopePager("subscriptions/subscriptionId", - &armlocks.ManagementLocksClientListByScopeOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armlocks/zz_generated_models_serde.go b/sdk/resourcemanager/resources/armlocks/zz_generated_models_serde.go deleted file mode 100644 index 0d07abb81622..000000000000 --- a/sdk/resourcemanager/resources/armlocks/zz_generated_models_serde.go +++ /dev/null @@ -1,92 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armlocks - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type ManagementLockProperties. -func (m ManagementLockProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "level", m.Level) - populate(objectMap, "notes", m.Notes) - populate(objectMap, "owners", m.Owners) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -}