From 1f713243f205e3fe9c9e818555209af042633cbc Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 30 Oct 2023 07:22:23 +0000 Subject: [PATCH] CodeGen from PR 3676 in openapi-env-test/azure-rest-api-specs Merge 8c7c5dc99229b065dc1e908c3d5c6c7904262c1e into 4068c6e2bf5a08621f310bc7c1ebd7f63b0b3649 --- .../armservicelinker/CHANGELOG.md | 23 + .../armservicelinker/autorest.md | 6 +- ...zz_generated_constants.go => constants.go} | 25 +- .../servicelinker/armservicelinker/go.mod | 16 +- .../servicelinker/armservicelinker/go.sum | 24 +- .../armservicelinker/linker_client.go | 160 +++ .../{zz_generated_models.go => models.go} | 29 +- .../armservicelinker/models_serde.go | 1273 +++++++++++++++++ ...rations_client.go => operations_client.go} | 2 +- ...phic_helpers.go => polymorphic_helpers.go} | 1 + ...ed_response_types.go => response_types.go} | 26 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 1 + ...ze_generated_example_linker_client_test.go | 219 --- ...enerated_example_operations_client_test.go | 41 - .../zz_generated_linker_client.go | 439 ------ .../zz_generated_models_serde.go | 582 -------- 16 files changed, 1485 insertions(+), 1382 deletions(-) rename sdk/resourcemanager/servicelinker/armservicelinker/{zz_generated_constants.go => constants.go} (90%) create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/linker_client.go rename sdk/resourcemanager/servicelinker/armservicelinker/{zz_generated_models.go => models.go} (95%) create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/models_serde.go rename sdk/resourcemanager/servicelinker/armservicelinker/{zz_generated_operations_client.go => operations_client.go} (98%) rename sdk/resourcemanager/servicelinker/armservicelinker/{zz_generated_polymorphic_helpers.go => polymorphic_helpers.go} (99%) rename sdk/resourcemanager/servicelinker/armservicelinker/{zz_generated_response_types.go => response_types.go} (53%) rename sdk/resourcemanager/servicelinker/armservicelinker/{zz_generated_time_rfc3339.go => time_rfc3339.go} (99%) delete mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go delete mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_operations_client_test.go delete mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go delete mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models_serde.go diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md b/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md index cac270158d1a..ac30df8ee7e9 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md +++ b/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md @@ -1,5 +1,28 @@ # Release History +## 2.0.0 (2023-10-30) +### Breaking Changes + +- Type of `ErrorAdditionalInfo.Info` has been changed from `any` to `interface{}` +- Function `NewClientFactory` has been removed +- Function `*ClientFactory.NewLinkerClient` has been removed +- Function `*ClientFactory.NewOperationsClient` has been removed +- Function `*LinkerClient.BeginCreateOrUpdate` has been removed +- Function `*LinkerClient.BeginDelete` has been removed +- Function `*LinkerClient.Get` has been removed +- Function `*LinkerClient.NewListPager` has been removed +- Function `*LinkerClient.BeginUpdate` has been removed +- Struct `ClientFactory` has been removed +- Struct `LinkerClientCreateOrUpdateResponse` has been removed +- Struct `LinkerClientDeleteResponse` has been removed +- Struct `LinkerClientListResponse` has been removed +- Struct `LinkerClientUpdateResponse` has been removed + +### Features Added + +- New value `ClientTypeKafkaSpringBoot` added to type alias `ClientType` + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker` 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/servicelinker/armservicelinker/autorest.md b/sdk/resourcemanager/servicelinker/armservicelinker/autorest.md index 7c484bb849fd..3736e38460d9 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/autorest.md +++ b/sdk/resourcemanager/servicelinker/armservicelinker/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicelinker/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicelinker/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/servicelinker/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/servicelinker/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 2.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go b/sdk/resourcemanager/servicelinker/armservicelinker/constants.go similarity index 90% rename from sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go rename to sdk/resourcemanager/servicelinker/armservicelinker/constants.go index bb82b66c87fa..94f670ea1c57 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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 armservicelinker const ( moduleName = "armservicelinker" - moduleVersion = "v1.0.0" + moduleVersion = "v2.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -67,16 +68,17 @@ func PossibleAzureResourceTypeValues() []AzureResourceType { type ClientType string const ( - ClientTypeDjango ClientType = "django" - ClientTypeDotnet ClientType = "dotnet" - ClientTypeGo ClientType = "go" - ClientTypeJava ClientType = "java" - ClientTypeNodejs ClientType = "nodejs" - ClientTypeNone ClientType = "none" - ClientTypePhp ClientType = "php" - ClientTypePython ClientType = "python" - ClientTypeRuby ClientType = "ruby" - ClientTypeSpringBoot ClientType = "springBoot" + ClientTypeDjango ClientType = "django" + ClientTypeDotnet ClientType = "dotnet" + ClientTypeGo ClientType = "go" + ClientTypeJava ClientType = "java" + ClientTypeKafkaSpringBoot ClientType = "kafka-springBoot" + ClientTypeNodejs ClientType = "nodejs" + ClientTypeNone ClientType = "none" + ClientTypePhp ClientType = "php" + ClientTypePython ClientType = "python" + ClientTypeRuby ClientType = "ruby" + ClientTypeSpringBoot ClientType = "springBoot" ) // PossibleClientTypeValues returns the possible values for the ClientType const type. @@ -86,6 +88,7 @@ func PossibleClientTypeValues() []ClientType { ClientTypeDotnet, ClientTypeGo, ClientTypeJava, + ClientTypeKafkaSpringBoot, ClientTypeNodejs, ClientTypeNone, ClientTypePhp, diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/go.mod b/sdk/resourcemanager/servicelinker/armservicelinker/go.mod index 9350335fc702..002b32a98f95 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/go.mod +++ b/sdk/resourcemanager/servicelinker/armservicelinker/go.mod @@ -1,21 +1,13 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker/v2 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.0.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 + github.com/davecgh/go-spew v1.1.1 // 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 + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/go.sum b/sdk/resourcemanager/servicelinker/armservicelinker/go.sum index ed5b814680ee..3afb578030a5 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/go.sum +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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/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= +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/servicelinker/armservicelinker/linker_client.go b/sdk/resourcemanager/servicelinker/armservicelinker/linker_client.go new file mode 100644 index 000000000000..f178c9adcad9 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/linker_client.go @@ -0,0 +1,160 @@ +//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 armservicelinker + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// LinkerClient contains the methods for the Linker group. +// Don't use this type directly, use NewLinkerClient() instead. +type LinkerClient struct { + host string + pl runtime.Pipeline +} + +// NewLinkerClient creates a new instance of LinkerClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewLinkerClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*LinkerClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &LinkerClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// ListConfigurations - list source configurations for a linker. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. +// linkerName - The name Linker resource. +// options - LinkerClientListConfigurationsOptions contains the optional parameters for the LinkerClient.ListConfigurations +// method. +func (client *LinkerClient) ListConfigurations(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientListConfigurationsOptions) (LinkerClientListConfigurationsResponse, error) { + req, err := client.listConfigurationsCreateRequest(ctx, resourceURI, linkerName, options) + if err != nil { + return LinkerClientListConfigurationsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LinkerClientListConfigurationsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LinkerClientListConfigurationsResponse{}, runtime.NewResponseError(resp) + } + return client.listConfigurationsHandleResponse(resp) +} + +// listConfigurationsCreateRequest creates the ListConfigurations request. +func (client *LinkerClient) listConfigurationsCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientListConfigurationsOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listConfigurationsHandleResponse handles the ListConfigurations response. +func (client *LinkerClient) listConfigurationsHandleResponse(resp *http.Response) (LinkerClientListConfigurationsResponse, error) { + result := LinkerClientListConfigurationsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SourceConfigurationResult); err != nil { + return LinkerClientListConfigurationsResponse{}, err + } + return result, nil +} + +// BeginValidate - Validate a link. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. +// linkerName - The name Linker resource. +// options - LinkerClientBeginValidateOptions contains the optional parameters for the LinkerClient.BeginValidate method. +func (client *LinkerClient) BeginValidate(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginValidateOptions) (*runtime.Poller[LinkerClientValidateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.validate(ctx, resourceURI, linkerName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[LinkerClientValidateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[LinkerClientValidateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Validate - Validate a link. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +func (client *LinkerClient) validate(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginValidateOptions) (*http.Response, error) { + req, err := client.validateCreateRequest(ctx, resourceURI, linkerName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// validateCreateRequest creates the Validate request. +func (client *LinkerClient) validateCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginValidateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models.go b/sdk/resourcemanager/servicelinker/armservicelinker/models.go similarity index 95% rename from sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models.go rename to sdk/resourcemanager/servicelinker/armservicelinker/models.go index 8c974a4187dc..efaf7d2b95b3 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models.go +++ b/sdk/resourcemanager/servicelinker/armservicelinker/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armservicelinker @@ -188,45 +189,17 @@ func (k *KeyVaultSecretURISecretInfo) GetSecretInfoBase() *SecretInfoBase { } } -// LinkerClientBeginCreateOrUpdateOptions contains the optional parameters for the LinkerClient.BeginCreateOrUpdate method. -type LinkerClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LinkerClientBeginDeleteOptions contains the optional parameters for the LinkerClient.BeginDelete method. -type LinkerClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LinkerClientBeginUpdateOptions contains the optional parameters for the LinkerClient.BeginUpdate method. -type LinkerClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // LinkerClientBeginValidateOptions contains the optional parameters for the LinkerClient.BeginValidate method. type LinkerClientBeginValidateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// LinkerClientGetOptions contains the optional parameters for the LinkerClient.Get method. -type LinkerClientGetOptions struct { - // placeholder for future optional parameters -} - // LinkerClientListConfigurationsOptions contains the optional parameters for the LinkerClient.ListConfigurations method. type LinkerClientListConfigurationsOptions struct { // placeholder for future optional parameters } -// LinkerClientListOptions contains the optional parameters for the LinkerClient.List method. -type LinkerClientListOptions struct { - // placeholder for future optional parameters -} - // LinkerList - The list of Linker. type LinkerList struct { // The link used to get the next page of Linker list. diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/models_serde.go b/sdk/resourcemanager/servicelinker/armservicelinker/models_serde.go new file mode 100644 index 000000000000..dbeb1bcbf553 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/models_serde.go @@ -0,0 +1,1273 @@ +//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 armservicelinker + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AuthInfoBase. +func (a AuthInfoBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["authType"] = a.AuthType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AuthInfoBase. +func (a *AuthInfoBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authType": + err = unpopulate(val, "AuthType", &a.AuthType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureKeyVaultProperties. +func (a AzureKeyVaultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "connectAsKubernetesCsiDriver", a.ConnectAsKubernetesCsiDriver) + objectMap["type"] = AzureResourceTypeKeyVault + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureKeyVaultProperties. +func (a *AzureKeyVaultProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connectAsKubernetesCsiDriver": + err = unpopulate(val, "ConnectAsKubernetesCsiDriver", &a.ConnectAsKubernetesCsiDriver) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureResource. +func (a AzureResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "resourceProperties", a.ResourceProperties) + objectMap["type"] = TargetServiceTypeAzureResource + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResource. +func (a *AzureResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "resourceProperties": + a.ResourceProperties, err = unmarshalAzureResourcePropertiesBaseClassification(val) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureResourcePropertiesBase. +func (a AzureResourcePropertiesBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["type"] = a.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResourcePropertiesBase. +func (a *AzureResourcePropertiesBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfluentBootstrapServer. +func (c ConfluentBootstrapServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "endpoint", c.Endpoint) + objectMap["type"] = TargetServiceTypeConfluentBootstrapServer + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfluentBootstrapServer. +func (c *ConfluentBootstrapServer) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endpoint": + err = unpopulate(val, "Endpoint", &c.Endpoint) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfluentSchemaRegistry. +func (c ConfluentSchemaRegistry) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "endpoint", c.Endpoint) + objectMap["type"] = TargetServiceTypeConfluentSchemaRegistry + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfluentSchemaRegistry. +func (c *ConfluentSchemaRegistry) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endpoint": + err = unpopulate(val, "Endpoint", &c.Endpoint) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type 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]interface{}) + 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 KeyVaultSecretReferenceSecretInfo. +func (k KeyVaultSecretReferenceSecretInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", k.Name) + objectMap["secretType"] = SecretTypeKeyVaultSecretReference + populate(objectMap, "version", k.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretReferenceSecretInfo. +func (k *KeyVaultSecretReferenceSecretInfo) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &k.Name) + delete(rawMsg, key) + case "secretType": + err = unpopulate(val, "SecretType", &k.SecretType) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &k.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultSecretURISecretInfo. +func (k KeyVaultSecretURISecretInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["secretType"] = SecretTypeKeyVaultSecretURI + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretURISecretInfo. +func (k *KeyVaultSecretURISecretInfo) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "secretType": + err = unpopulate(val, "SecretType", &k.SecretType) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerList. +func (l LinkerList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkerList. +func (l *LinkerList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerPatch. +func (l LinkerPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkerPatch. +func (l *LinkerPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerProperties. +func (l LinkerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authInfo", l.AuthInfo) + populate(objectMap, "clientType", l.ClientType) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "scope", l.Scope) + populate(objectMap, "secretStore", l.SecretStore) + populate(objectMap, "targetService", l.TargetService) + populate(objectMap, "vNetSolution", l.VNetSolution) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkerProperties. +func (l *LinkerProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authInfo": + l.AuthInfo, err = unmarshalAuthInfoBaseClassification(val) + delete(rawMsg, key) + case "clientType": + err = unpopulate(val, "ClientType", &l.ClientType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &l.Scope) + delete(rawMsg, key) + case "secretStore": + err = unpopulate(val, "SecretStore", &l.SecretStore) + delete(rawMsg, key) + case "targetService": + l.TargetService, err = unmarshalTargetServiceBaseClassification(val) + delete(rawMsg, key) + case "vNetSolution": + err = unpopulate(val, "VNetSolution", &l.VNetSolution) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerResource. +func (l LinkerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkerResource. +func (l *LinkerResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + 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 "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + 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]interface{}) + populate(objectMap, "description", o.Description) + 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 "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, 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]interface{}) + 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 ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecretAuthInfo. +func (s SecretAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["authType"] = AuthTypeSecret + populate(objectMap, "name", s.Name) + populate(objectMap, "secretInfo", s.SecretInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretAuthInfo. +func (s *SecretAuthInfo) 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 "authType": + err = unpopulate(val, "AuthType", &s.AuthType) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "secretInfo": + s.SecretInfo, err = unmarshalSecretInfoBaseClassification(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecretInfoBase. +func (s SecretInfoBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["secretType"] = s.SecretType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretInfoBase. +func (s *SecretInfoBase) 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 "secretType": + err = unpopulate(val, "SecretType", &s.SecretType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecretStore. +func (s SecretStore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "keyVaultId", s.KeyVaultID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretStore. +func (s *SecretStore) 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 "keyVaultId": + err = unpopulate(val, "KeyVaultID", &s.KeyVaultID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServicePrincipalCertificateAuthInfo. +func (s ServicePrincipalCertificateAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["authType"] = AuthTypeServicePrincipalCertificate + populate(objectMap, "certificate", s.Certificate) + populate(objectMap, "clientId", s.ClientID) + populate(objectMap, "principalId", s.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalCertificateAuthInfo. +func (s *ServicePrincipalCertificateAuthInfo) 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 "authType": + err = unpopulate(val, "AuthType", &s.AuthType) + delete(rawMsg, key) + case "certificate": + err = unpopulate(val, "Certificate", &s.Certificate) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &s.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &s.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServicePrincipalSecretAuthInfo. +func (s ServicePrincipalSecretAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["authType"] = AuthTypeServicePrincipalSecret + populate(objectMap, "clientId", s.ClientID) + populate(objectMap, "principalId", s.PrincipalID) + populate(objectMap, "secret", s.Secret) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalSecretAuthInfo. +func (s *ServicePrincipalSecretAuthInfo) 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 "authType": + err = unpopulate(val, "AuthType", &s.AuthType) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &s.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &s.PrincipalID) + delete(rawMsg, key) + case "secret": + err = unpopulate(val, "Secret", &s.Secret) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceConfiguration. +func (s SourceConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceConfiguration. +func (s *SourceConfiguration) 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 "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceConfigurationResult. +func (s SourceConfigurationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "configurations", s.Configurations) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceConfigurationResult. +func (s *SourceConfigurationResult) 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 "configurations": + err = unpopulate(val, "Configurations", &s.Configurations) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemAssignedIdentityAuthInfo. +func (s SystemAssignedIdentityAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["authType"] = AuthTypeSystemAssignedIdentity + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemAssignedIdentityAuthInfo. +func (s *SystemAssignedIdentityAuthInfo) 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 "authType": + err = unpopulate(val, "AuthType", &s.AuthType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetServiceBase. +func (t TargetServiceBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["type"] = t.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetServiceBase. +func (t *TargetServiceBase) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentityAuthInfo. +func (u UserAssignedIdentityAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["authType"] = AuthTypeUserAssignedIdentity + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "subscriptionId", u.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentityAuthInfo. +func (u *UserAssignedIdentityAuthInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authType": + err = unpopulate(val, "AuthType", &u.AuthType) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &u.SubscriptionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VNetSolution. +func (v VNetSolution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VNetSolution. +func (v *VNetSolution) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateOperationResult. +func (v ValidateOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "resourceId", v.ResourceID) + populate(objectMap, "status", v.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateOperationResult. +func (v *ValidateOperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &v.ResourceID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &v.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateResult. +func (v ValidateResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authType", v.AuthType) + populate(objectMap, "isConnectionAvailable", v.IsConnectionAvailable) + populate(objectMap, "linkerName", v.LinkerName) + populateTimeRFC3339(objectMap, "reportEndTimeUtc", v.ReportEndTimeUTC) + populateTimeRFC3339(objectMap, "reportStartTimeUtc", v.ReportStartTimeUTC) + populate(objectMap, "sourceId", v.SourceID) + populate(objectMap, "targetId", v.TargetID) + populate(objectMap, "validationDetail", v.ValidationDetail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateResult. +func (v *ValidateResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authType": + err = unpopulate(val, "AuthType", &v.AuthType) + delete(rawMsg, key) + case "isConnectionAvailable": + err = unpopulate(val, "IsConnectionAvailable", &v.IsConnectionAvailable) + delete(rawMsg, key) + case "linkerName": + err = unpopulate(val, "LinkerName", &v.LinkerName) + delete(rawMsg, key) + case "reportEndTimeUtc": + err = unpopulateTimeRFC3339(val, "ReportEndTimeUTC", &v.ReportEndTimeUTC) + delete(rawMsg, key) + case "reportStartTimeUtc": + err = unpopulateTimeRFC3339(val, "ReportStartTimeUTC", &v.ReportStartTimeUTC) + delete(rawMsg, key) + case "sourceId": + err = unpopulate(val, "SourceID", &v.SourceID) + delete(rawMsg, key) + case "targetId": + err = unpopulate(val, "TargetID", &v.TargetID) + delete(rawMsg, key) + case "validationDetail": + err = unpopulate(val, "ValidationDetail", &v.ValidationDetail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidationResultItem. +func (v ValidationResultItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", v.Description) + populate(objectMap, "errorCode", v.ErrorCode) + populate(objectMap, "errorMessage", v.ErrorMessage) + populate(objectMap, "name", v.Name) + populate(objectMap, "result", v.Result) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidationResultItem. +func (v *ValidationResultItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &v.Description) + delete(rawMsg, key) + case "errorCode": + err = unpopulate(val, "ErrorCode", &v.ErrorCode) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &v.ErrorMessage) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "result": + err = unpopulate(val, "Result", &v.Result) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValueSecretInfo. +func (v ValueSecretInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["secretType"] = SecretTypeRawValue + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValueSecretInfo. +func (v *ValueSecretInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "secretType": + err = unpopulate(val, "SecretType", &v.SecretType) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_operations_client.go b/sdk/resourcemanager/servicelinker/armservicelinker/operations_client.go similarity index 98% rename from sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_operations_client.go rename to sdk/resourcemanager/servicelinker/armservicelinker/operations_client.go index fc3fda26c097..991afd9de620 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_operations_client.go +++ b/sdk/resourcemanager/servicelinker/armservicelinker/operations_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 armservicelinker @@ -49,7 +50,6 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO } // NewListPager - Lists the available ServiceLinker REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2022-05-01 // options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/servicelinker/armservicelinker/polymorphic_helpers.go similarity index 99% rename from sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/servicelinker/armservicelinker/polymorphic_helpers.go index 94ea80336605..bdd497a1738b 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/servicelinker/armservicelinker/polymorphic_helpers.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 armservicelinker diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go b/sdk/resourcemanager/servicelinker/armservicelinker/response_types.go similarity index 53% rename from sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go rename to sdk/resourcemanager/servicelinker/armservicelinker/response_types.go index 4ebf1684f969..5cea3c45b821 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go +++ b/sdk/resourcemanager/servicelinker/armservicelinker/response_types.go @@ -5,39 +5,15 @@ // 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 armservicelinker -// LinkerClientCreateOrUpdateResponse contains the response from method LinkerClient.CreateOrUpdate. -type LinkerClientCreateOrUpdateResponse struct { - LinkerResource -} - -// LinkerClientDeleteResponse contains the response from method LinkerClient.Delete. -type LinkerClientDeleteResponse struct { - // placeholder for future response values -} - -// LinkerClientGetResponse contains the response from method LinkerClient.Get. -type LinkerClientGetResponse struct { - LinkerResource -} - // LinkerClientListConfigurationsResponse contains the response from method LinkerClient.ListConfigurations. type LinkerClientListConfigurationsResponse struct { SourceConfigurationResult } -// LinkerClientListResponse contains the response from method LinkerClient.List. -type LinkerClientListResponse struct { - LinkerList -} - -// LinkerClientUpdateResponse contains the response from method LinkerClient.Update. -type LinkerClientUpdateResponse struct { - LinkerResource -} - // LinkerClientValidateResponse contains the response from method LinkerClient.Validate. type LinkerClientValidateResponse struct { ValidateOperationResult diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_time_rfc3339.go b/sdk/resourcemanager/servicelinker/armservicelinker/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/servicelinker/armservicelinker/time_rfc3339.go index edb565fe38d1..c7c0e007186f 100644 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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 armservicelinker diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go b/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go deleted file mode 100644 index 4330afd2d9e2..000000000000 --- a/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go +++ /dev/null @@ -1,219 +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 armservicelinker_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/servicelinker/armservicelinker" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/LinkList.json -func ExampleLinkerClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - 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/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/Link.json -func ExampleLinkerClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - "linkName", - 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/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLink.json -func ExampleLinkerClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - "linkName", - armservicelinker.LinkerResource{ - Properties: &armservicelinker.LinkerProperties{ - AuthInfo: &armservicelinker.SecretAuthInfo{ - AuthType: to.Ptr(armservicelinker.AuthTypeSecret), - Name: to.Ptr("name"), - SecretInfo: &armservicelinker.ValueSecretInfo{ - SecretType: to.Ptr(armservicelinker.SecretTypeRawValue), - Value: to.Ptr("secret"), - }, - }, - TargetService: &armservicelinker.AzureResource{ - Type: to.Ptr(armservicelinker.TargetServiceTypeAzureResource), - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforPostgreSQL/servers/test-pg/databases/test-db"), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/DeleteLink.json -func ExampleLinkerClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - "linkName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PatchLink.json -func ExampleLinkerClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - "linkName", - armservicelinker.LinkerPatch{ - Properties: &armservicelinker.LinkerProperties{ - AuthInfo: &armservicelinker.ServicePrincipalSecretAuthInfo{ - AuthType: to.Ptr(armservicelinker.AuthTypeServicePrincipalSecret), - ClientID: to.Ptr("name"), - PrincipalID: to.Ptr("id"), - Secret: to.Ptr("secret"), - }, - TargetService: &armservicelinker.AzureResource{ - Type: to.Ptr(armservicelinker.TargetServiceTypeAzureResource), - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DocumentDb/databaseAccounts/test-acc/mongodbDatabases/test-db"), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/ValidateLinkSuccess.json -func ExampleLinkerClient_BeginValidate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginValidate(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - "linkName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/GetConfigurations.json -func ExampleLinkerClient_ListConfigurations() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewLinkerClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListConfigurations(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app", - "linkName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_operations_client_test.go deleted file mode 100644 index 0d17af596596..000000000000 --- a/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_operations_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 armservicelinker_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armservicelinker.NewOperationsClient(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/servicelinker/armservicelinker/zz_generated_linker_client.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go deleted file mode 100644 index 713c83a0d710..000000000000 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go +++ /dev/null @@ -1,439 +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 armservicelinker - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// LinkerClient contains the methods for the Linker group. -// Don't use this type directly, use NewLinkerClient() instead. -type LinkerClient struct { - host string - pl runtime.Pipeline -} - -// NewLinkerClient creates a new instance of LinkerClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewLinkerClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*LinkerClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &LinkerClient{ - host: ep, - pl: pl, - } - return client, nil -} - -// BeginCreateOrUpdate - Create or update linker resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// linkerName - The name Linker resource. -// parameters - Linker details. -// options - LinkerClientBeginCreateOrUpdateOptions contains the optional parameters for the LinkerClient.BeginCreateOrUpdate -// method. -func (client *LinkerClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, linkerName string, parameters LinkerResource, options *LinkerClientBeginCreateOrUpdateOptions) (*runtime.Poller[LinkerClientCreateOrUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceURI, linkerName, parameters, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[LinkerClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[LinkerClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) - } -} - -// CreateOrUpdate - Create or update linker resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -func (client *LinkerClient) createOrUpdate(ctx context.Context, resourceURI string, linkerName string, parameters LinkerResource, options *LinkerClientBeginCreateOrUpdateOptions) (*http.Response, error) { - req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, linkerName, parameters, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *LinkerClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, linkerName string, parameters LinkerResource, options *LinkerClientBeginCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - if linkerName == "" { - return nil, errors.New("parameter linkerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) -} - -// BeginDelete - Delete a link. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// linkerName - The name Linker resource. -// options - LinkerClientBeginDeleteOptions contains the optional parameters for the LinkerClient.BeginDelete method. -func (client *LinkerClient) BeginDelete(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginDeleteOptions) (*runtime.Poller[LinkerClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceURI, linkerName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[LinkerClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[LinkerClientDeleteResponse](options.ResumeToken, client.pl, nil) - } -} - -// Delete - Delete a link. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -func (client *LinkerClient) deleteOperation(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceURI, linkerName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *LinkerClient) deleteCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - if linkerName == "" { - return nil, errors.New("parameter linkerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Returns Linker resource for a given name. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// linkerName - The name Linker resource. -// options - LinkerClientGetOptions contains the optional parameters for the LinkerClient.Get method. -func (client *LinkerClient) Get(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientGetOptions) (LinkerClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, resourceURI, linkerName, options) - if err != nil { - return LinkerClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return LinkerClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LinkerClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *LinkerClient) getCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientGetOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - if linkerName == "" { - return nil, errors.New("parameter linkerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *LinkerClient) getHandleResponse(resp *http.Response) (LinkerClientGetResponse, error) { - result := LinkerClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.LinkerResource); err != nil { - return LinkerClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - Returns list of Linkers which connects to the resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// options - LinkerClientListOptions contains the optional parameters for the LinkerClient.List method. -func (client *LinkerClient) NewListPager(resourceURI string, options *LinkerClientListOptions) *runtime.Pager[LinkerClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[LinkerClientListResponse]{ - More: func(page LinkerClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *LinkerClientListResponse) (LinkerClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceURI, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return LinkerClientListResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return LinkerClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LinkerClientListResponse{}, runtime.NewResponseError(resp) - } - return client.listHandleResponse(resp) - }, - }) -} - -// listCreateRequest creates the List request. -func (client *LinkerClient) listCreateRequest(ctx context.Context, resourceURI string, options *LinkerClientListOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *LinkerClient) listHandleResponse(resp *http.Response) (LinkerClientListResponse, error) { - result := LinkerClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.LinkerList); err != nil { - return LinkerClientListResponse{}, err - } - return result, nil -} - -// ListConfigurations - list source configurations for a linker. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// linkerName - The name Linker resource. -// options - LinkerClientListConfigurationsOptions contains the optional parameters for the LinkerClient.ListConfigurations -// method. -func (client *LinkerClient) ListConfigurations(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientListConfigurationsOptions) (LinkerClientListConfigurationsResponse, error) { - req, err := client.listConfigurationsCreateRequest(ctx, resourceURI, linkerName, options) - if err != nil { - return LinkerClientListConfigurationsResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return LinkerClientListConfigurationsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LinkerClientListConfigurationsResponse{}, runtime.NewResponseError(resp) - } - return client.listConfigurationsHandleResponse(resp) -} - -// listConfigurationsCreateRequest creates the ListConfigurations request. -func (client *LinkerClient) listConfigurationsCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientListConfigurationsOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - if linkerName == "" { - return nil, errors.New("parameter linkerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listConfigurationsHandleResponse handles the ListConfigurations response. -func (client *LinkerClient) listConfigurationsHandleResponse(resp *http.Response) (LinkerClientListConfigurationsResponse, error) { - result := LinkerClientListConfigurationsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SourceConfigurationResult); err != nil { - return LinkerClientListConfigurationsResponse{}, err - } - return result, nil -} - -// BeginUpdate - Operation to update an existing link. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// linkerName - The name Linker resource. -// parameters - Linker details. -// options - LinkerClientBeginUpdateOptions contains the optional parameters for the LinkerClient.BeginUpdate method. -func (client *LinkerClient) BeginUpdate(ctx context.Context, resourceURI string, linkerName string, parameters LinkerPatch, options *LinkerClientBeginUpdateOptions) (*runtime.Poller[LinkerClientUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceURI, linkerName, parameters, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[LinkerClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[LinkerClientUpdateResponse](options.ResumeToken, client.pl, nil) - } -} - -// Update - Operation to update an existing link. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -func (client *LinkerClient) update(ctx context.Context, resourceURI string, linkerName string, parameters LinkerPatch, options *LinkerClientBeginUpdateOptions) (*http.Response, error) { - req, err := client.updateCreateRequest(ctx, resourceURI, linkerName, parameters, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// updateCreateRequest creates the Update request. -func (client *LinkerClient) updateCreateRequest(ctx context.Context, resourceURI string, linkerName string, parameters LinkerPatch, options *LinkerClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - if linkerName == "" { - return nil, errors.New("parameter linkerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) -} - -// BeginValidate - Validate a link. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -// resourceURI - The fully qualified Azure Resource manager identifier of the resource to be connected. -// linkerName - The name Linker resource. -// options - LinkerClientBeginValidateOptions contains the optional parameters for the LinkerClient.BeginValidate method. -func (client *LinkerClient) BeginValidate(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginValidateOptions) (*runtime.Poller[LinkerClientValidateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.validate(ctx, resourceURI, linkerName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[LinkerClientValidateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[LinkerClientValidateResponse](options.ResumeToken, client.pl, nil) - } -} - -// Validate - Validate a link. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-05-01 -func (client *LinkerClient) validate(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginValidateOptions) (*http.Response, error) { - req, err := client.validateCreateRequest(ctx, resourceURI, linkerName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// validateCreateRequest creates the Validate request. -func (client *LinkerClient) validateCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerClientBeginValidateOptions) (*policy.Request, error) { - urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" - urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) - if linkerName == "" { - return nil, errors.New("parameter linkerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models_serde.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models_serde.go deleted file mode 100644 index 3ca32fb05739..000000000000 --- a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models_serde.go +++ /dev/null @@ -1,582 +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 armservicelinker - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AzureKeyVaultProperties. -func (a AzureKeyVaultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectAsKubernetesCsiDriver", a.ConnectAsKubernetesCsiDriver) - objectMap["type"] = AzureResourceTypeKeyVault - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureKeyVaultProperties. -func (a *AzureKeyVaultProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectAsKubernetesCsiDriver": - err = unpopulate(val, "ConnectAsKubernetesCsiDriver", &a.ConnectAsKubernetesCsiDriver) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AzureResource. -func (a AzureResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "resourceProperties", a.ResourceProperties) - objectMap["type"] = TargetServiceTypeAzureResource - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResource. -func (a *AzureResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &a.ID) - delete(rawMsg, key) - case "resourceProperties": - a.ResourceProperties, err = unmarshalAzureResourcePropertiesBaseClassification(val) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ConfluentBootstrapServer. -func (c ConfluentBootstrapServer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "endpoint", c.Endpoint) - objectMap["type"] = TargetServiceTypeConfluentBootstrapServer - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ConfluentBootstrapServer. -func (c *ConfluentBootstrapServer) 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", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "endpoint": - err = unpopulate(val, "Endpoint", &c.Endpoint) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ConfluentSchemaRegistry. -func (c ConfluentSchemaRegistry) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "endpoint", c.Endpoint) - objectMap["type"] = TargetServiceTypeConfluentSchemaRegistry - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ConfluentSchemaRegistry. -func (c *ConfluentSchemaRegistry) 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", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "endpoint": - err = unpopulate(val, "Endpoint", &c.Endpoint) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type KeyVaultSecretReferenceSecretInfo. -func (k KeyVaultSecretReferenceSecretInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", k.Name) - objectMap["secretType"] = SecretTypeKeyVaultSecretReference - populate(objectMap, "version", k.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretReferenceSecretInfo. -func (k *KeyVaultSecretReferenceSecretInfo) 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", k, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &k.Name) - delete(rawMsg, key) - case "secretType": - err = unpopulate(val, "SecretType", &k.SecretType) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &k.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", k, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type KeyVaultSecretURISecretInfo. -func (k KeyVaultSecretURISecretInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["secretType"] = SecretTypeKeyVaultSecretURI - populate(objectMap, "value", k.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultSecretURISecretInfo. -func (k *KeyVaultSecretURISecretInfo) 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", k, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "secretType": - err = unpopulate(val, "SecretType", &k.SecretType) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &k.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", k, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type LinkerPatch. -func (l LinkerPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", l.Properties) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LinkerProperties. -func (l LinkerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "authInfo", l.AuthInfo) - populate(objectMap, "clientType", l.ClientType) - populate(objectMap, "provisioningState", l.ProvisioningState) - populate(objectMap, "scope", l.Scope) - populate(objectMap, "secretStore", l.SecretStore) - populate(objectMap, "targetService", l.TargetService) - populate(objectMap, "vNetSolution", l.VNetSolution) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LinkerProperties. -func (l *LinkerProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "authInfo": - l.AuthInfo, err = unmarshalAuthInfoBaseClassification(val) - delete(rawMsg, key) - case "clientType": - err = unpopulate(val, "ClientType", &l.ClientType) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) - delete(rawMsg, key) - case "scope": - err = unpopulate(val, "Scope", &l.Scope) - delete(rawMsg, key) - case "secretStore": - err = unpopulate(val, "SecretStore", &l.SecretStore) - delete(rawMsg, key) - case "targetService": - l.TargetService, err = unmarshalTargetServiceBaseClassification(val) - delete(rawMsg, key) - case "vNetSolution": - err = unpopulate(val, "VNetSolution", &l.VNetSolution) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SecretAuthInfo. -func (s SecretAuthInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["authType"] = AuthTypeSecret - populate(objectMap, "name", s.Name) - populate(objectMap, "secretInfo", s.SecretInfo) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SecretAuthInfo. -func (s *SecretAuthInfo) 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 "authType": - err = unpopulate(val, "AuthType", &s.AuthType) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &s.Name) - delete(rawMsg, key) - case "secretInfo": - s.SecretInfo, err = unmarshalSecretInfoBaseClassification(val) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServicePrincipalCertificateAuthInfo. -func (s ServicePrincipalCertificateAuthInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["authType"] = AuthTypeServicePrincipalCertificate - populate(objectMap, "certificate", s.Certificate) - populate(objectMap, "clientId", s.ClientID) - populate(objectMap, "principalId", s.PrincipalID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalCertificateAuthInfo. -func (s *ServicePrincipalCertificateAuthInfo) 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 "authType": - err = unpopulate(val, "AuthType", &s.AuthType) - delete(rawMsg, key) - case "certificate": - err = unpopulate(val, "Certificate", &s.Certificate) - delete(rawMsg, key) - case "clientId": - err = unpopulate(val, "ClientID", &s.ClientID) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &s.PrincipalID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ServicePrincipalSecretAuthInfo. -func (s ServicePrincipalSecretAuthInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["authType"] = AuthTypeServicePrincipalSecret - populate(objectMap, "clientId", s.ClientID) - populate(objectMap, "principalId", s.PrincipalID) - populate(objectMap, "secret", s.Secret) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalSecretAuthInfo. -func (s *ServicePrincipalSecretAuthInfo) 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 "authType": - err = unpopulate(val, "AuthType", &s.AuthType) - delete(rawMsg, key) - case "clientId": - err = unpopulate(val, "ClientID", &s.ClientID) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &s.PrincipalID) - delete(rawMsg, key) - case "secret": - err = unpopulate(val, "Secret", &s.Secret) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SystemAssignedIdentityAuthInfo. -func (s SystemAssignedIdentityAuthInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["authType"] = AuthTypeSystemAssignedIdentity - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemAssignedIdentityAuthInfo. -func (s *SystemAssignedIdentityAuthInfo) 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 "authType": - err = unpopulate(val, "AuthType", &s.AuthType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentityAuthInfo. -func (u UserAssignedIdentityAuthInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["authType"] = AuthTypeUserAssignedIdentity - populate(objectMap, "clientId", u.ClientID) - populate(objectMap, "subscriptionId", u.SubscriptionID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentityAuthInfo. -func (u *UserAssignedIdentityAuthInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "authType": - err = unpopulate(val, "AuthType", &u.AuthType) - delete(rawMsg, key) - case "clientId": - err = unpopulate(val, "ClientID", &u.ClientID) - delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &u.SubscriptionID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateResult. -func (v *ValidateResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "authType": - err = unpopulate(val, "AuthType", &v.AuthType) - delete(rawMsg, key) - case "isConnectionAvailable": - err = unpopulate(val, "IsConnectionAvailable", &v.IsConnectionAvailable) - delete(rawMsg, key) - case "linkerName": - err = unpopulate(val, "LinkerName", &v.LinkerName) - delete(rawMsg, key) - case "reportEndTimeUtc": - err = unpopulateTimeRFC3339(val, "ReportEndTimeUTC", &v.ReportEndTimeUTC) - delete(rawMsg, key) - case "reportStartTimeUtc": - err = unpopulateTimeRFC3339(val, "ReportStartTimeUTC", &v.ReportStartTimeUTC) - delete(rawMsg, key) - case "sourceId": - err = unpopulate(val, "SourceID", &v.SourceID) - delete(rawMsg, key) - case "targetId": - err = unpopulate(val, "TargetID", &v.TargetID) - delete(rawMsg, key) - case "validationDetail": - err = unpopulate(val, "ValidationDetail", &v.ValidationDetail) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ValueSecretInfo. -func (v ValueSecretInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["secretType"] = SecretTypeRawValue - populate(objectMap, "value", v.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ValueSecretInfo. -func (v *ValueSecretInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "secretType": - err = unpopulate(val, "SecretType", &v.SecretType) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &v.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -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 -}